0

I'm trying to specify a meta object for a route auto-generated for me by Gridsome, like this:

meta: {
      auth: true
    }

But there isn't a normal routes/index.js file in Gridsome - only a router object exposed like this in index.js:

export default function (Vue, { router, head, isClient }) 
{}

How do I reach into the router and add the meta to the specific routes I want to modify?

skunkwerk
  • 2,920
  • 2
  • 37
  • 55

1 Answers1

0

You can get the route object via this inside components script tag

<script>
export default {
  created () {
    this.$route.meta = {requiresAuth: true}    
  }
}
</script>
Nehal Hasnayeen
  • 1,203
  • 12
  • 23
  • I dont think thats working "Cannot assign to read only property 'meta' of object '#'" – scar Oct 13 '20 at 14:55