-
Notifications
You must be signed in to change notification settings - Fork 509
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(macros): add XsltSidebar for XSLT pages (#9021)
Co-authored-by: Claas Augner <495429+caugner@users.noreply.github.com>
- Loading branch information
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |