Skip to content

Commit

Permalink
Filter submenu items
Browse files Browse the repository at this point in the history
  • Loading branch information
chgeo committed Nov 28, 2024
1 parent ea32612 commit 9ec39a8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 3 additions & 3 deletions .vitepress/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions about/bad-practices.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
# status: released
---

# Bad Practices

[[toc]]
Expand Down

0 comments on commit 9ec39a8

Please sign in to comment.