Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Rendering an InlineCard in a custom macro

Mason Palos July 29, 2022

Hello.

I'm writing a custom macro for Confluence that lists all of the outgoing links on a page. I want it to look like this mockup:

chrome_r9vwaKO7Wx.png

So far, I'm requesting the content of the body of the page, and storing the url properties of all InlineCard objects in an array.

I would like to render the links in my macro in the same "smart link" style as the InlineCards in the body if possible. But I can't find any documentation on how to achieve this. Is this possible at all?

1 answer

0 votes
Bill Bailey
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 29, 2022

Take a look at the rendered HTML from the InlineCards. It may be as simple as reusing the CSS class (and imitating the structure).

Mason Palos July 29, 2022

My problem is that, the page's content retrieved by running

api.asUser().requestConfluence(route`/wiki/rest/api/content/${contentId}?expand=body.atlas_doc_format`);

contains the InlineCard objects, which have this structure:

{ "type": "inlineCard", "attrs": { "url": "https://atlassian.com" } }

The objects contain the property for the URL which they point to, but no property for the page title. To be able to build a list of hyperlinks with the URL + the title of the page they point to, I would have to request the page data using each URL I stored, and pull the page title/icon from that. This is presumably just what InlineCard does in the backend, so I would be effectively rewriting what InlineCard does already, which I would prefer not to do, but if there's no sort of API or library I could find for this, then I will likely have to go that route!

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events