nuxtjs-named-routes
v1.0.5
Published
A Nuxt.js module that sets router named routes from nuxt.config file
Downloads
4
Readme
nuxtjs-named-routes
A Nuxt.js module that sets router named routes from nuxt.config file
Features
- Nuxt 3 support
- Sets router named routes from nuxt.config file
Setup
- Add
nuxtjs-named-routes
dependency to your project
yarn add nuxtjs-named-routes # or npm install nuxtjs-named-routes
- Add
nuxtjs-named-routes
to themodules
section ofnuxt.config.ts
export default defineNuxtConfig({
modules: [
'nuxtjs-named-routes'
],
namedRoutes: {
routes: {
'custom-key': {
path: '/custom-url-for-homepage',
file: '/pages/homepage.vue'
}
}
}
}
- Use the named route
<NuxtLink :to="{name: 'custom-key'}">Link to the homepage</NuxtLink>
The code above will generate HTML link
<a href="/custom-url-for-homepage">Link to the homepage</a>
Options
routes
- Type:
Object
- Default:
{}
routes: {
'named-route-key': {
path: '/url-path',
file: '/pages/homepage.vue'
}
}
License
Copyright (c) - Tibor Piňo