diff --git a/docs/_includes/grouped-pages.njk b/docs/_includes/grouped-pages.njk index 7c06d0b3a..2273f4c98 100644 --- a/docs/_includes/grouped-pages.njk +++ b/docs/_includes/grouped-pages.njk @@ -3,8 +3,8 @@
{% set groupedPages = allPages | groupPages(categories, page) %} {% for category, pages in groupedPages -%} - {% if groupedPages.meta.groupCount > 1 %} -

+ {% if groupedPages.meta.groupCount > 1 and pages.length > 0 %} +

{% if pages.meta.url %}{{ pages.meta.title }} {% else %} {{ pages.meta.title }} diff --git a/docs/_includes/sidebar-link.njk b/docs/_includes/sidebar-link.njk index 261a272ec..d44628b07 100644 --- a/docs/_includes/sidebar-link.njk +++ b/docs/_includes/sidebar-link.njk @@ -1,4 +1,4 @@ -{% if not (isAlpha and page.data.noAlpha) and not page.data.unlisted -%} +{% if page | show -%}
  • {{ page.data.title }} {% if page.data.status == 'experimental' %}{% endif %} diff --git a/docs/_utils/filters.js b/docs/_utils/filters.js index f81e5b909..9747a78b3 100644 --- a/docs/_utils/filters.js +++ b/docs/_utils/filters.js @@ -178,6 +178,10 @@ export function sort(arr, by = { 'data.order': 1, 'data.title': '' }) { }); } +export function show(page) { + return !(page.data.noAlpha && page.data.isAlpha) && !page.data.unlisted; +} + /** * Group an 11ty collection (or any array of objects with a `data.tags` property) by certain tags. * @param {object[]} collection @@ -198,7 +202,7 @@ export function groupPages(collection, options = {}, page) { options = { tags: options }; } - let { tags, groups, titles = {}, other = 'Other' } = options; + let { tags, groups, titles = {}, other = 'Other', filter = show } = options; if (groups === undefined && Array.isArray(tags)) { groups = tags; @@ -237,6 +241,10 @@ export function groupPages(collection, options = {}, page) { let byUrl = {}; let byParentUrl = {}; + if (filter) { + collection = collection.filter(filter); + } + for (let item of collection) { let url = item.page.url; let parentUrl = item.data.parentUrl; @@ -313,6 +321,13 @@ export function groupPages(collection, options = {}, page) { if (sortedGroups) { ret = sortObject(ret, sortedGroups); + } else { + // At least make sure other is last + if (ret.other) { + let otherGroup = ret.other; + delete ret.other; + ret.other = otherGroup; + } } Object.defineProperty(ret, 'meta', { diff --git a/docs/_utils/outline.js b/docs/_utils/outline.js index 0281ee66b..026a59e00 100644 --- a/docs/_utils/outline.js +++ b/docs/_utils/outline.js @@ -39,7 +39,7 @@ export function outlinePlugin(options = {}) { } // Create a clone of the heading so we can remove links and [data-no-outline] elements from the text content - clone.querySelectorAll('a').forEach(a => a.remove()); + clone.querySelectorAll('.wa-visually-hidden, [hidden], [aria-hidden="true"]').forEach(el => el.remove()); clone.querySelectorAll('[data-no-outline]').forEach(el => el.remove()); // Generate the link