diff --git a/src/runtime/server/api/navigation.ts b/src/runtime/server/api/navigation.ts index 4f11e3063..46c5c54ae 100644 --- a/src/runtime/server/api/navigation.ts +++ b/src/runtime/server/api/navigation.ts @@ -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() 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