This macro dynamically generates a table of contents for the direct child pages of the current Confluence page. It uses the Confluence REST API to retrieve child pages and their content in JSON format. It identifies H1 headings in the child pages and renders them as anchor links within an unordered list. The table of contents updates automatically as the child pages or headings change.
## Get children of the current page
#set ( $children = $ConfluenceManager.get("/wiki/api/v2/pages/${page.id}/children").results )
<ul>
#if($children.isEmpty())
No children pages were found for current page
#else
#foreach ( $child in $children )
## Get child content in JSON format
#set ( $body = $ConfluenceManager.get("/wiki/api/v2/pages/${child.id}?body-format=atlas_doc_format").body.atlas_doc_format.value )
<li><b>$child.title</b><br>
#set ( $devider = "" ) ## skip first devider
#foreach ( $item in $body.content )
## Triggers only on H1 headings
#if ( $item.type == "heading" && $item.attrs.level == 1)
#set ( $h1 = $item.content[0].text )
$devider
## Render anchor link
<ac:link ac:anchor="$h1">
<ri:page ri:content-title="$child.title"/>
<ac:plain-text-link-body><![CDATA[$h1]]></ac:plain-text-link-body>
</ac:link>
#set ( $devider = "|" )
#end
#end
</li>
#end
#end
</ul>Display the top comments from a selected Confluence page or the current page by default.
Shows all attachments from the current space in a table view
Perform customized searches based on labels, content types, and other parameters.
Display page edit and view restrictions in Confluence to get essential permission details, including users, groups, and inherited access.
Generate a list of all the content created by a current user by default or a specified user across your Confluence site.
Display information about how many users have access to each space
An overview of all pages within one space which contains the title, the version, and the last updated date
Find image within page attachments. Handy for reuse files and update them all at once
Read and display the fixed version of Confluence pages by checking page or ancestor labels
Basic greeting for user