From ef284a18ef0e6461ba8c12a0387faef30c91ac1d Mon Sep 17 00:00:00 2001 From: Maxime Pauvert Date: Fri, 20 Jun 2025 16:57:45 +0200 Subject: [PATCH 1/3] Update 2.query-collection-navigation.md --- .../4.utils/2.query-collection-navigation.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/docs/content/docs/4.utils/2.query-collection-navigation.md b/docs/content/docs/4.utils/2.query-collection-navigation.md index 50e1acce4..79beab91b 100644 --- a/docs/content/docs/4.utils/2.query-collection-navigation.md +++ b/docs/content/docs/4.utils/2.query-collection-navigation.md @@ -143,6 +143,24 @@ Make sure to create `server/tsconfig.json` file with the following content to av Content module provides some extra utilities to simplify common use cases like building breadcrumb navigation. +### `findPageHeadline(navigation, path, options?)` + +Returns the headline (name of the parent folder) for a given path within a navigation tree. Useful for displaying section titles or contextual navigation headers. + +- `navigation`: The navigation tree (array of ContentNavigationItem). +- `path`: The current page path. +- `options` (optional): + - `indexAsChild`: Treat index pages as children. + +**Example:** + +```ts +import { findPageBreadcrumb } from '@nuxt/content/utils' + +const breadcrumb = findPageBreadcrumb(navigation, '/docs/guide/getting-started') +// breadcrumb is an array of navigation items leading to the current page +``` + ### `findPageBreadcrumb(navigation, path, options?)` Returns the breadcrumb trail (array of navigation items) for a given path within a navigation tree. Useful for building breadcrumb navigation components. From a060131b6e0ac9410f278d0f69dd51cf61a1080b Mon Sep 17 00:00:00 2001 From: Farnabaz Date: Mon, 23 Jun 2025 11:03:38 +0200 Subject: [PATCH 2/3] Apply suggestions from code review --- docs/content/docs/4.utils/2.query-collection-navigation.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/docs/content/docs/4.utils/2.query-collection-navigation.md b/docs/content/docs/4.utils/2.query-collection-navigation.md index 79beab91b..f67185a7a 100644 --- a/docs/content/docs/4.utils/2.query-collection-navigation.md +++ b/docs/content/docs/4.utils/2.query-collection-navigation.md @@ -155,11 +155,10 @@ Returns the headline (name of the parent folder) for a given path within a navig **Example:** ```ts -import { findPageBreadcrumb } from '@nuxt/content/utils' +import { findPageHeadline } from '@nuxt/content/utils' -const breadcrumb = findPageBreadcrumb(navigation, '/docs/guide/getting-started') -// breadcrumb is an array of navigation items leading to the current page -``` +const headline = findPageHeadline(navigation, '/docs/guide/getting-started') +// headline is a string containing the name of the parent folder ### `findPageBreadcrumb(navigation, path, options?)` From e3441c89fee1ec2da1debd4017e80f50fc25681f Mon Sep 17 00:00:00 2001 From: Farnabaz Date: Mon, 23 Jun 2025 11:07:20 +0200 Subject: [PATCH 3/3] Update 2.query-collection-navigation.md --- docs/content/docs/4.utils/2.query-collection-navigation.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/content/docs/4.utils/2.query-collection-navigation.md b/docs/content/docs/4.utils/2.query-collection-navigation.md index f67185a7a..d36009bbe 100644 --- a/docs/content/docs/4.utils/2.query-collection-navigation.md +++ b/docs/content/docs/4.utils/2.query-collection-navigation.md @@ -158,7 +158,8 @@ Returns the headline (name of the parent folder) for a given path within a navig import { findPageHeadline } from '@nuxt/content/utils' const headline = findPageHeadline(navigation, '/docs/guide/getting-started') -// headline is a string containing the name of the parent folder +// headline is a string that contains the name of the parent folder +``` ### `findPageBreadcrumb(navigation, path, options?)`