nuxt / content

The file-based CMS for your Nuxt application, powered by Markdown and Vue components.
https://content.nuxt.com
MIT License
3.02k stars 615 forks source link

Breadcrumbs object for SEO easy navigation #1718

Open hermesalvesbr opened 1 year ago

hermesalvesbr commented 1 year ago

Is your feature request related to a problem? Please describe

Today to make a breadcrumbs nav is complex, because in my language the words have special characters.

Describe the solution you'd like

If the composable navigation had a breadcrumbs object it would solve this.

Describe alternatives you've considered

Today we use packages that have integration with nuxt, but there is nothing for nuxt content 2.

Additional context

A simple breadcrumbs can also be used to assemble menus, logic of what the user has already visited and what remains to be visited.

image

nicolas-bastien commented 1 year ago

I would be nice to generate breadcrumb in json ld format based on content structure. In the same way we have dynamic navigation

dxlliv commented 7 months ago

Et voilà


const {page} = useContent()

const breadcrumbs = []
const pagePathExploded = page.value._path.split('/')

let tmpPagePath = ''

for (const pagePathItem of pagePathExploded) {
  if (pagePathItem === '') continue

  tmpPagePath += `/${pagePathItem}`

  breadcrumbs.push(await queryContent(tmpPagePath).only(['title', '_path']).findOne())
}

console.log(breadcrumbs)
dxlliv commented 7 months ago

Anyway yes, having a content helper for this would be helpful but it's probably better to build your own function

shiny commented 1 month ago

that's what i looking for!