Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/runtime/server/api/navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ export default defineEventHandler(async (event) => {
* Partial contents are not included in the navigation
* A partial content is a content that has `_` prefix in its path
*/
_partial: false
_partial: false,
/**
* Exclude any pages which have opted out of navigation via frontmatter.
*/
navigation: {
$ne: false
}
})
.find()

Expand Down
6 changes: 6 additions & 0 deletions test/features/navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,11 @@ export const testNavigation = () => {
expect(item.title).toEqual(String(fibo[index]))
})
})

test('Should remove `navigation-disabled.md` content', async () => {
const list = await $fetch('/api/_content/navigation/')
const hidden = list.find(i => i._path === '/navigation-disabled')
expect(hidden).toBeUndefined()
})
})
}
7 changes: 7 additions & 0 deletions test/fixtures/basic/content/navigation-disabled.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
navigation: false
---

# Hidden from navigation

Basic description