1.0.5 • Published 2 years ago

nuxtjs-named-routes v1.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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

  1. Add nuxtjs-named-routes dependency to your project
yarn add nuxtjs-named-routes # or npm install nuxtjs-named-routes
  1. Add nuxtjs-named-routes to the modules section of nuxt.config.ts
export default defineNuxtConfig({
  modules: [
    'nuxtjs-named-routes'
  ],
  namedRoutes: {
    routes: {
        'custom-key': {
            path: '/custom-url-for-homepage',
            file: '/pages/homepage.vue'
        }
    }
  }
}
  1. 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

MIT License

Copyright (c) - Tibor Piňo

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago