Finding documents by tag

I am making an affiliate webshop with products in various categories and I am using tags for the different products.

I am trying to make a dynamic route based on a specific tag

/search/tags/:tag

to display all products with that specific tag, f.x. "Kitchen".

but I am getting a 404 on that route.

My folder structure for the route are

search

  • tags
    • _uid

I have this in my linkResolver.js

if (doc.type === 'homepage') {
return '/'
}

if (doc.type === 'product') {
return '/products/' + doc.uid
}

if (doc.type === 'category') {
return '/categories/' + doc.uid
}

Do I need to create a "Tags" single type in Prismic or can I have Nuxt handle the route in the default way with some Prismic querying?

Any help is very much appreciated.

It's easy to overcomplicate things! :)

Got it solved by

router: {
routes: [
{
path: '/search/tags/:tag',
component: 'pages/search/tags/_uid',
},
],
},

and

const products = await $prismic.api.query($prismic.predicates.at('document.tags', [params.uid]), { orderings: '[my.product.title desc]' })

Welcome to the community. I'm glad that you solved it. Don't hesitate to reach out us if you have any doubt.
Thanks.