Omnislash
Nuxt nested layout
Hello
I have exactly the same question I think ^^
Let's say I have 3 elements on my page :
- menu
- submenu
- page
I want my menu to be there no matter what, but my submenu only on certain pages
What I would like to do is something like :
- menu.vue (layout)
- submenu.vue (layout) that includes the menu
- page.vue (page) that includes the submenu (and thus the menu)
In your solution, what I would need to do is either :
- Add a condition to load the submenu depending on the page/route
- Add the menu in my layouts
The first solution feels clonky with extra verification. The second is "fine", I would have the menu as a code repetition, but by making it a component at least the modifications will be centralized
Is there a way to nest layouts, or should I treat the "menu" layout as a component and include it in all my layouts ?
Thanks 🙂
10 replies
dumb question: cache usage with useFetch
I think it's best to look at it this way :
If it's light without that much navigation, trust at first and see how it goes
If it's specific with a lot of navigation and enough data so you want to limitate stuff, and build a quick one with pinia ? Or still easy enough to do your own anyway, just have to be more promise conscious
39 replies
dumb question: cache usage with useFetch
Had the same problem month ago.
I don't know if it's a good idea but I strongly wanted to have my hand on the data and strop firing fetch all the time.
I didn't want to use pinia for other reasons, so I just developped a little fetch abstraction that store the calls in a dictionnary using the endpoint as the key for the get.
If I call it again, it'll return me the dictionnary first, and refresh it at the same time if I want to
39 replies
Is there a way to create a dynamic payload for static site?
Oh ok just understood the question :x
Indeed CROS is server-side @Kaloyanes
I do use Notion as a CMS myself so it works, but I guess they prevent it from the browser since you should never use your access or API Keys from you front
That being said, the notion api response time is underwhelming, especially since you usually need more than one call to have all the info you want to display on one page, so I ended up using postgres as a "cache"
26 replies
Is there a way to create a dynamic payload for static site?
That being said, you have a public and a private env. You can access the public env on the client side.
It's here in runtime config : https://nuxt.com/docs/guide/going-further/runtime-config
You just have to prefix the variable with NUXT_PUBLIC_
26 replies
Is there a way to create a dynamic payload for static site?
My bad ofc it doesn't work, I use nuxt just as a front, so fetch works but it indeed fetches data from elsewhere ^^"""
I would argue you indeed can't have the server side in any static hosting. So if cpanel only does static hosting.....
26 replies
Is there a way to create a dynamic payload for static site?
I understand it's not the answer your are expecting, but you might want to consider cloudflare pages instead ?
It's free up to pretty far and you'll most likely have less deployment restrictions ?
26 replies