Hi there,
Is it possible to define route meta fields as per https://router.vuejs.org/en/advanced/meta.html ?
Cheers.
I think nuxt.js use the middleware for check or do something before route .
you can define middleware in you page vue file
index.vue
export default {
middleware: 'auth'
}
middleware/auth.js
export default function ({ store, redirect }) {
if (store.getters.isAuth) {
return redirect('/')
}
}
or check this Auth0 example form nuxt.js
The thing i'm looking for is a per-route config that i can access in my layout, which changes certain things visually based on the route. Before migrating the project to nuxt I achieved this using by setting data on the route as per https://router.vuejs.org/en/advanced/meta.html
Hi @samturrell , have you tried to use store
with getters?
@alexchopin would it be difficult to expose to meta property on a page component? Trying to implement a page crumbs implementation right now and being ability to set the meta property on the page routes would greatly simplify this.
Hi @uptownhr,
I am actually implementing meta
property in page components and will be available in next release :)
@Atinux I'm assuming this is a part of 1.0, but no docs yet. Have any info for me to use right now?
checking out, https://github.com/nuxt/nuxt.js/blob/dev/lib/common/utils.js doesn't look like the router meta is being populated in any way. Are we planning on adding this feature later?
@uptownhr actually it's in app/utils.js
, see https://github.com/nuxt/nuxt.js/blob/dev/lib/app/utils.js#L96
Actually you can play with it easily by adding a meta
property in your page and ready it in your middlewares (ex: https://github.com/nuxt/nuxt.js/blob/20b548a17523e54d7f24cede4ada358d359e6f78/test/fixtures/basic/middleware/meta.js)
Oh nice. Let me give it a shot.
On Tue, Feb 6, 2018, 4:18 AM Sébastien Chopin notifications@github.com
wrote:
@uptownhr https://github.com/uptownhr actually it's in `app/utils.js,
see https://github.com/nuxt/nuxt.js/blob/dev/lib/app/utils.js#L96Actually you can play with it easily by adding a meta property in your
page and ready it in your middlewares (ex:
https://github.com/nuxt/nuxt.js/blob/20b548a17523e54d7f24cede4ada358d359e6f78/test/fixtures/basic/middleware/meta.js
)—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/nuxt/nuxt.js/issues/466#issuecomment-363405384, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AA-UtlpJN3b-BOURwv6CQL5zDYGX2m9aks5tSEL_gaJpZM4MsBc0
.
There is a good practice here:
https://github.com/nuxt/nuxt.js/issues/1687#issuecomment-331870619
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
Hi @uptownhr,
I am actually implementing
meta
property in page components and will be available in next release :)