I want to route pages depend on incoming url. I have 2 different pages which works like a slug. I need to create my url like in samples. Is there any way to check url params and route them to right slug page inside extendRoutes or somewhere else which will not affect page load speed ?
page
--_category
--subcategory
sample url
http://192.168.52.215:3000/news. :category slug
http://192.168.52.215:3000/local-news. :subcategory slug
extendRoutes(routes, resolve) {
{
name: 'category',
path: '/:category',
component: resolve('pages/_category.vue'),
},
{
name: 'category',
path: '/:subcategory',
component: resolve('pages/subcategory.vue'),
},
);
For example , if my paramater includes news, it should go _category slug otherwise it should go to subcategory slug
you can change name for routes like this
extendRoutes(routes, resolve) {
{
name: 'category',
path: '/:category',
component: resolve('pages/_category.vue'),
},
{
name: 'subcategory',
path: '/:subcategory',
component: resolve('pages/subcategory.vue'),
}
);
And when you try to navigate do this :
// Navigate to Category Slug
this.$router.push({ name: 'category': params: { category: 'news' } });
// Navigate to Subcategory Slug
this.$router.push({ name: 'subcategory': params: { subcategory: 'local-news' } });