#Is dynamic routes with specific values possible?

2 messages · Page 1 of 1 (latest)

torpid steeple
#

Hello, I have the following structure

└── pages
    ├── now
    │   └── index.vue
    │   └── [productId].vue
    │   └── [categoryId].vue
    │   └── [brandId].vue
    ├── later
    │   └── [productId].vue
    │   └── [categoryId].vue
    │   └── [brandId].vue

As you can see, I'm duplicating the same pages (with the same content inside too). The only difference is I pass either now or later in the corresponding page to fetch its data.
Is there way to set a dynamic page but with only now or later as possible values built-in? Or should I create the following structure and check for now or later in pages/type.vue and otherwise do other stuff?

└── pages
    ├── [type]
    │   └── index.vue
    │   └── [productId].vue
    │   └── [categoryId].vue
    │   └── [brandId].vue
cedar surge
#

I think you can achieve this using pages:extend hook or router config file as described here.

https://nuxt.com/docs/guide/going-further/custom-routing

Then you can create custom routes for each of your files without having to duplicate them.

Nuxt

In Nuxt 3, your routing is defined by the structure of your files inside the pages directory. However, since it uses vue-router under the hood, Nuxt offers you several ways to add custom routes in your project.