question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to specify route name

See original GitHub issue

Hello, is there a way how to specify a name for a generated route?

In the default setup, the route name is inferred (hopeI am not mistaken) from the directory structure. That’s cool for smaller not deeply nested routes however it would be handy if I could specify route name in the page component itself.

E.g.: it would be taken from the page component name:

// users/_id/orders/_page.vue
<script>
export default {
  name: 'user-orders'
}
</script>

I am sorry if I missed something obvious.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:16 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
jantajovcommented, Dec 12, 2019

Any progress about this?

Meanwhile I came up with following workaround:

import generatedRoutes from 'vue-auto-routing'

for (let route of generatedRoutes) {
  if (route.meta && route.meta.name) {
    route.name = route.meta.name
  }
}

You have to specify the route name in the route-meta block and then you can override it.

Your page component would look like this:

<route-meta>{"name": "contact-card-update"}</route-meta>

<template>
  <div>{{hello}}</div>
</template>

<script> 
.... 
</script>
2reactions
ktsncommented, Sep 22, 2019

We cannot specify it currently. Maybe I’ll add <route-config> custom block and let specify the name in the block.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Routing - Laravel - The PHP Framework For Web Artisans
Route names should always be unique. Generating URLs To Named Routes. Once you have assigned a name to a given route, you may...
Read more >
Add name to laravel route - Stack Overflow
Option 1. Route::get('/novanoticia', 'HomeController@getNovaNoticia')->name('route_name');. Option 2. Route::get('/novanoticia', ['as' ...
Read more >
What is the use of Route Name? - Laracasts
Named routes allow you to conveniently generate URLs or redirects for a specific route. You may specify a name for a route using...
Read more >
Route Names and Route Orders in Attribute Routing
To specify the route name, we need to set the Name property on the attribute. Let us see an example to understand how...
Read more >
Routing to controller actions in ASP.NET Core - Microsoft Learn
The route names give the route a logical name. The named route can be used for URL generation. Using a named route simplifies...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found