This Confluence user macro calls the Confluence REST API to fetch pages a label using CQL. The result is rendered as a AUI-styled list with a header and CSV download button.
## Specify a label name parameter
#set($label = $parameters["label"])
#if(!$label)
<div class="aui-message aui-message-info">
Please provide a <code>label</code> parameter.
</div>
#else
## Fetch pages for a specific label
#set($response = $ConfluenceManager.get("/wiki/rest/api/content/search?cql=type=page AND label='$label'"))
#set($results = $response.results)
#set($base = $response._links.base)
<div id="label-header" data-label="$!label" style="display:flex; align-items:center; gap:12px; margin-bottom:8px;">
<div>
<span class="aui-lozenge aui-lozenge-subtle aui-lozenge-inprogress">Showing pages for label:</span> <span class="aui-lozenge aui-lozenge-subtle aui-lozenge-new">$!label</span>
</div>
<button title="Download CSV" id="download-csv-btn"
type="button"
aria-label="Download CSV"
style="
display:inline-flex;
align-items:center;
gap:8px;
background-color:#1868DB;
color:#fff;
border:0;
border-radius:4px;
padding:6px 12px;
cursor:pointer;
font-family:inherit;
font-size:14px;
box-shadow: 0 2px 2px rgba(25,118,210,0.2);
">
<span class="iconify" data-icon="ph:download" data-inline="false" style="font-size:18px;"></span>
</button>
</div>
## Create a list of pages
#if($response)
<ul id="label-pages-list" style="padding-left:18px;">
#foreach($page in $results)
#set($title = $page.title)
#set($webui = $page._links.webui)
#set($href = "${base}$webui")
<li data-title="$!title" style="list-style-type: circle;"><a href="$!href" target="_blank" rel="noopener noreferrer">$!title</a></li>
#end
</ul>
#else
<div>
No pages found for label <code>$!label</code>.
</div>
#end
<script type="module">
(function () {
const btn = document.getElementById('download-csv-btn');
const list = document.getElementById('label-pages-list');
const header = document.getElementById('label-header');
if (!btn) return;
const label = (header && header.dataset && header.dataset.label) ? header.dataset.label: 'pages';
const safeFilename = (name) => String(name).replace(/\s+/g, '_') + '-pages.csv';
const escapeCsvField = (s) => {
if (s == null) return '';
s = String(s);
if (/[",\r\n]/.test(s)) {
return '"' + s.replace(/"/g, '""') + '"';
}
return s;
};
const buildCsv = () => {
const rows = [];
rows.push(['Title', 'URL'].map(escapeCsvField).join(','));
if (!list) return rows.join('\r\n');
for (const li of list.querySelectorAll('li')) {
const a = li.querySelector('a');
const title = li.getAttribute('data-title') || (a ? a.textContent.trim(): '');
const url = a ? a.href: '';
rows.push([title, url].map(escapeCsvField).join(','));
}
return rows.join('\r\n');
};
const downloadBlob = (content, filename) => {
const blob = new Blob([content], {
type: 'text/csv;charset=utf-8;'
});
if (navigator.msSaveBlob) {
navigator.msSaveBlob(blob, filename);
return;
}
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.setAttribute('download', filename);
a.style.display = 'none';
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url);
};
btn.addEventListener('click', (e) => {
e.preventDefault();
const csv = buildCsv();
const filename = safeFilename(label);
downloadBlob(csv, filename);
});
})();
</script>
<script>
if (!window.iconifyOnLoad) {
(function() {
const s = document.createElement('script');
s.src = 'https://code.iconify.design/2/2.2.1/iconify.min.js';
s.defer = true;
document.head.appendChild(s);
window.iconifyOnLoad = true;
})();
}
</script>
#endRetrieve and display labels from a specified space
Space Information macro by space Id
Generate a list of labels from all spaces leading to corresponding content pages, organized in alphabetical order.
Displays a list of pages in specific space with certain title or label
Display page edit and view restrictions in Confluence to get essential permission details, including users, groups, and inherited access.
Shows page creation date
Show an expandable page tree for a selected parent page (defaults to the current page)
Filter Confluence groups based on a specified filter value and display the results in different formats.
Shows H1 headings directly to children's topics for easy navigation.
Basic greeting for user