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
## Note that not all Atlaskit design tokens (example: var(--ds-text, #ffffff)) work in static macros. Check that case by case
#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 from the current page by default
Show all attachments from the current space in a sortable table view
Perform customized searches based on labels, content types, and other parameters
Dynamically list all child pages of the current page in a table format
Display Confluence page edit and view restrictions to provide essential permission details, including users, groups, and inherited access
Generate a list of all content created by the current user by default, or by a specified user, across your Confluence site
Display the number of users who have access to each space
Display an overview of all pages in a space, including title, version, and last updated date
Find images within page attachments. Handy for reusing files and updating them all at once.
Read and display the fixed version of Confluence pages by checking page or ancestor labels