NuxtN
Nuxt2y ago
14 replies
Alexandre Nédélec

Pass extra dynamic data when routing to a page

I need to pass some extra data to my page in addition to the route and query parameters.

The problem:
I'm migrating my blog to Nuxt Content and I have a page /tags/{tag} that display articles concerning a specific tag. Some articles contain tags like "GitHub Actions" or "CI/CD" that give the following URLs /tags/github-actions or tags/cicd . I need to have the same URLs to avoid redirections but with these URLs with a modified tag (github-actions instead of github%20actions for example) I won't be able to retrieve the original tag to display it on my page and retrieve related articles.

If the modified tag ( github-actions ) is passed as a route parameter I need a way to pass the original tag (GitHub Actions) as well.

What solutions I have considered:
- Pass the original as query parameter => my existing tags URL will still break without the additional query parameter
- Use navigation guards to make some sort of redirection => not exactly sure how it could work and it seems complex
- once on the tag page, retrieve all blog posts, map their tags to the modified tags version to get the original tags and the corresponding articles => it seems to be a complicated workaround
Was this page helpful?