Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to Dynamically Generate Dynamic Breadcrumbs #327

Closed
thorge opened this issue Oct 4, 2024 · 2 comments · Fixed by #331
Closed

Unable to Dynamically Generate Dynamic Breadcrumbs #327

thorge opened this issue Oct 4, 2024 · 2 comments · Fixed by #331

Comments

@thorge
Copy link
Contributor

thorge commented Oct 4, 2024

I am trying to create breadcrumbs that dynamically reflect route parameters in Nuxt, specifically for routes with dynamic segments. For example, when editing a user at the route /users/:userId/edit, the breadcrumbs should look like this: Users > :userId > Edit.

I understand that I can use overrides with useBreadcrumbItems() to manually define the breadcrumb structure, but the challenge arises when different routes require different overrides. Since useBreadcrumbItems() can only be used at the top level of the setup function, I am unable to recreate or modify the breadcrumb items based on route changes. This results in errors when trying to update the breadcrumbs dynamically as the route changes.

Is there a recommended way to handle this scenario where breadcrumbs need to be updated dynamically based on route parameters?

@FlorientPlouvin
Copy link

FlorientPlouvin commented Oct 10, 2024

Same problem here, I need to change label of items depending query parameters in my url. I tried to use computed but nothing change

@thorge
Copy link
Contributor Author

thorge commented Oct 11, 2024

In order to enable computed values for overrides, a simple enhancement can be made by utilizing toValue. Specifically, this line of code:

const overrides = options.overrides || []

Could be adjusted as follows:

const overrides = toValue(options.overrides || []);

This will ensure that both static and reactive values are properly handled within the overrides option.

If you'd like, I can set up a PR to implement these changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants