Description
I’d like to propose moving the [findPageBreadcrumb](https://ui.nuxt.com/getting-started/content#findpagebreadcrumb)
function, currently implemented in @nuxt/ui-pro
to the @nuxt/content
module. Since it relies solely on content data, it could be useful beyond Nuxt UI and benefit a broader range of projects using Nuxt Content.
Following a conversation with @atinux in DMs, he mentioned this move could indeed make sense and be worth considering within the scope of @nuxt/content
.
In addition, I’d like to propose the creation of two complementary utilities:
findPageChildren
findPageSiblings
🧠 Proposal
1. Generic utilities
All three functions (findPageBreadcrumb
, findPageChildren
, and findPageSiblings
) could:
- Accept a route string (e.g.
/foo/bar
) rather than a full page object. - Support an optional
strategy
parameter to control howindex.md
files are interpreted.
findPageBreadcrumb(navigation?: ContentNavigationItem[], route?: string, options?: {current: boolean, strategy?: 'index-as-root' | 'index-as-child'})
findPageChildren(navigation?: ContentNavigationItem[], route?: string, options?: {strategy?: 'index-as-root' | 'index-as-child'})
findPageSiblings(navigation?: ContentNavigationItem[], route?: string, options?: {strategy?: 'index-as-root' | 'index-as-child'})
2. Strategy behavior
The strategy
option would define whether an index.md
file should be:
- considered a child page within its directory (
index-as-child
, current behavior) - considered the root page of its directory (
index-as-root
)
It would also be convenient to define this behavior globally through the module configuration, e.g.:
export default defineNuxtConfig({
content: {
navigation: {
strategy: 'index-as-root' // or 'index-as-child'
}
}
})
📎 Context
Related PRs in @nuxt/ui-pro
: