Skip to content

Commit

Permalink
feat(macros): add XsltSidebar for XSLT pages (#9021)
Browse files Browse the repository at this point in the history
Co-authored-by: Claas Augner <495429+caugner@users.noreply.github.com>
  • Loading branch information
bsmth and caugner authored Jun 5, 2023
1 parent e704315 commit bddd9f7
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions kumascript/macros/XsltSidebar.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<%
async function renderRootItem(slug) {
const [link, title] = await getPageLinkAndTitle(slug);
return `<li><a href="${link}"><strong>${title}</strong></a></li>`
}
async function getPageLinkAndTitle(slug) {
let link = `/${env.locale}${slug}`;
let page = await wiki.getPage(link);
if (!page.title && env.locale !== 'en-US') {
link = `/en-US${slug}`;
page = await wiki.getPage(link);
}
let title = page.short_title || page.title;
title = mdn.htmlEscape(title);
return [link, title];
}
%>

<section id="Quick_links" data-macro="XsltSidebar">
<ol>
<%- await renderRootItem("/docs/Web/XSLT") %>
<%- await template("ListSubpagesForSidebar", ['/docs/Web/XSLT/Transforming_XML_with_XSLT', 1]) %>
</ol>
<ol>
<%- await renderRootItem("/docs/Web/XSLT/Element") %>
<%- await template("ListSubpagesForSidebar", ['/docs/Web/XSLT/Element', 1]) %>
</ol>
<ol>
<%- await renderRootItem("/docs/Web/EXSLT") %>
<%- await template("ListSubpagesForSidebar", ['/docs/Web/EXSLT', 1]) %>
</ol>
<ol>
<%- await renderRootItem("/docs/Web/XPath/Functions") %>
<%- await template("ListSubpagesForSidebar", ['/docs/Web/XPath/Functions', 1]) %>
</ol>
<ol>
<%- await renderRootItem("/docs/Web/XPath/Axes") %>
</ol>
</section>

0 comments on commit bddd9f7

Please sign in to comment.