I am very new to vue/nuxt and got stuck with this issue when implementing the frontend for a headless cms.
I have two routes as such
Pages
-StandardPage
->_standardPage.vue
-InfoPage
->_InfoPage.vue
My _standardPage.vue and _infoPage.vue has this code (same for now but will change) Basicly they need a guid Id to fetch page information from the Api. The page information contains different blocks that then are dynamicly generated components:
<template>
<div>
<Menu />
<div v-for="block in site.blocks" :key="block.id">
<component :is="block.blockName" :blockData="block"/>
</div>
</div>
</template>
<script>
export default{
data(){
return {
site: Object
}},
methods: {
this.site = result from async method, calling api to get page info by guid id (how do i get a hold of this guid)
}
}
now the problem is that in my menu component im doing a fetch to get the menu display name and corresponding pageId (menu items can be added/removed on a whim so I have no way of knowing beforehand those Ids), When I click a menu item i wish to pass along the page Id to my standard or info page so they can fetch corresponding data but to no success.
I have tried to $emit from child to parent but I have no success in doing that across routes. If i do a $router.push with path and query I get a nasty guid in the url and that does not look very friendly.
What would be the best way to pass my guid from my menu component to my routed pages?