From 9ec39a88f880cf51af77aee75d6288fffc7ec814 Mon Sep 17 00:00:00 2001 From: Christian Georgi Date: Thu, 28 Nov 2024 10:48:36 +0100 Subject: [PATCH] Filter submenu items --- .vitepress/menu.js | 6 +++--- about/bad-practices.md | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.vitepress/menu.js b/.vitepress/menu.js index b7a5a11d1..b436f21d8 100644 --- a/.vitepress/menu.js +++ b/.vitepress/menu.js @@ -44,10 +44,10 @@ export class MenuItem { * Reads a submenu from the given file and adds all its items * into this item's child items. */ - async include (filename, parent='.', _rewrite = rewrites) { + async include (filename, parent='.', _rewrite = rewrites, include, exclude) { const root = dirname(parent), folder = dirname(filename) const rewrite = link => link[0] === '/' ? link : _rewrite (normalize(join(folder,link))) - const {items} = await Menu.from (join(root,filename), rewrite) + const {items} = await Menu.from (join(root,filename), rewrite, include, exclude) const children = this.items ??= []; children.push (...items) this.link = '/'+folder+'/' this.collapsed = true @@ -92,7 +92,7 @@ export class Menu extends MenuItem { // Add new item to parent, and to the stack of children let child = !text ? parent : children[hashes.length] = parent.add (text, link) - if (is_submenu) await child.include (link, file, rewrite, !text) + if (is_submenu) await child.include (link, file, rewrite, include, exclude) } // Return menu when all includes are done diff --git a/about/bad-practices.md b/about/bad-practices.md index 113e534cd..7b3cd4727 100644 --- a/about/bad-practices.md +++ b/about/bad-practices.md @@ -1,3 +1,7 @@ +--- +# status: released +--- + # Bad Practices [[toc]]