diff --git a/src/runtime/server/api/navigation.ts b/src/runtime/server/api/navigation.ts index 4f11e3063..f6d85a803 100644 --- a/src/runtime/server/api/navigation.ts +++ b/src/runtime/server/api/navigation.ts @@ -8,6 +8,14 @@ export default defineEventHandler(async (event) => { const query: Partial = getContentQuery(event) const contents = await serverQueryContent(event, query) + .where({ + /** + * Exclude any pages which have opted out of navigation via frontmatter. + */ + navigation: { + $ne: false + } + }) .where({ /** * Partial contents are not included in the navigation diff --git a/test/features/navigation.ts b/test/features/navigation.ts index 3a72a9fc6..647130db0 100644 --- a/test/features/navigation.ts +++ b/test/features/navigation.ts @@ -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() + }) }) } diff --git a/test/fixtures/basic/content/navigation-disabled.md b/test/fixtures/basic/content/navigation-disabled.md new file mode 100644 index 000000000..73a14154e --- /dev/null +++ b/test/fixtures/basic/content/navigation-disabled.md @@ -0,0 +1,7 @@ +--- +navigation: false +--- + +# Hidden from navigation + +Basic description