Created
November 7, 2019 20:37
-
-
Save nilocoelhojunior/522c6695c46a851671edf88d8551a79a to your computer and use it in GitHub Desktop.
Breadcrumb to Nuxtjs
for me breadcrumbArray[idx - 1].path
didnt work, i had to change it to breadcrumbArray[idx - 1].title
here's a cleaner splitting function I've used https://stackoverflow.com/questions/67104312/using-slice-function-for-breadcrumb-routes
just need to replace
final.push({
label: array[i],
to: `/${array.slice(1,i+1).join('/').toString()}`
})
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Really nice. But if the search engine navigates you to something like "example.com/about/" it will create a crumb of "undefined" because it splits at the last "/". To prevent this you could add an
if (path) {}
around thebreadcrumbArray.push()
.