Kérunix
Unknown order of nested routes
I believe the best way to handle such a problem would be using query params instead of actual route parameters like this:
/index?time=[7,15]&latitude=[40,50]
or /index?latitude=[40,50]&longitude=[20,30]&time=[15,23]
.
These allow any order and can be optionnal, while still rendering a single page that can bind to the query using useRoute()
so you can read and manipulate them based on your filters.7 replies
How to make a CodeGroup like on Nuxt UI Pro,
I guess you could use headless ui's tab component for the layout and shiki for the syntx highlighting.
2 replies
"router-link-active" not added when on sub route
I'm not sure of the correct answer here since the formatting of your message might mislead me (maybe navigate to your
pages
directory and show us the output of tree
so we can understand how your pages are organised).
But if the formating is correct in your post, then categories.vue
and /categories
should be on the same level as /posts/index.vue
for Vue Router to set the correct classes.4 replies
Nuxt i18n module v-html xss warning
Well technically there is an alternative but that is only useful if you want to interpolate some html content in a string that lives in your translations files. The example they give in the docs with an anchor tag inserted in some text is exactly the kind of use case for that feature.
If your content is only html then v-html with trusted content is the way to go
8 replies
State managment
Hey there.
I'd say you don't have to use one over the other. The two are really for different use cases. If you want simple, small, SSR safe and reactive state (something like a simple array of user notifications, or a cookie value), you can stick to
useState
.
But as soon as you start doing something like useMyState
that derives values from your simple state (i.e. computed
properties based on state), or that handles manipulating deeply nested state objects, that's when I'd go for Pinia which is really tailored for that sort of things.
Note that if you really don't want to use Pinia you can still use composables and make your own reactive state management using only useState
but at this point you'd be reinventing the wheel that Pinia made for us 🙂3 replies
Nuxt i18n module v-html xss warning
The XSS warning is here just as, well, a warning. It signals you that you are injecting raw HTML into your page, which can lead to an XSS attack if the content comes from an untrusted source (ie. user generated content). If you are the one generating the content (from a CMS or even by storing raw html strings in a DB), this should not be an issue.
As stated in the docs, "Only use HTML interpolation on trusted content and never on user-provided content." and "If the message contains HTML, Vue I18n outputs a warning to console when development mode" so this warning won't be logged in production.
8 replies
Fetching related data sequentially
This works fine no problem, the issue I have is for fetching the "secondary" data, I need to know which posts I get before I fetch their authors, and this can be achieved through a watcher but can become cumbersome if there's a lot of nested relations to fetch like user > comments > posts > authors for example.
The solution from Woutercouvaras looks more like something that would work for me, chaining promises to fetch all the nested data based on an array of urls.
13 replies