saltytostitos
saltytostitos
NNuxt
Created by eyJOdnJHb25uYSI6Imd2VXVwIn0= on 12/21/2023 in #❓・help
Organize folders?
Move your profile.vue into /profile as an index.vue file
/profile/index.vue
/profile/index.vue
(just saw Bric's reply!)
6 replies
NNuxt
Created by jd on 8/22/2024 in #❓・help
Best way to save user context to avoid needing to fetch at every page?
The most simple and rudimentary way to save some state is
useState('id')
useState('id')
There are many best practices for something like this, but useState will get the job done. Context: https://nuxt.com/docs/api/composables/use-state Watch the video from Lichter linked on the page. My second favorite would be using KV Cache in your Nitro layer, depending on your environment.
defineCachedEventHandler()
defineCachedEventHandler()
https://www.youtube.com/watch?v=KN5e2Hh6uC0
3 replies
NNuxt
Created by FoxForGate on 7/26/2024 in #❓・help
Is it possible to use a custom icon in NuxtUI "<UIcon />"?
I'm using this way in nuxt.config (referencing svgs)
icon: {customCollections: [{ prefix: "local", dir: "./app/assets/icons" }]},
icon: {customCollections: [{ prefix: "local", dir: "./app/assets/icons" }]},
Then use
<UIcon name="local:filename" />
<UIcon name="local:filename" />
context: https://github.com/nuxt/icon?tab=readme-ov-file#custom-local-collections
4 replies
NNuxt
Created by xmatthias on 8/18/2024 in #❓・help
Nitro scheduledTask cloudflare
I don't know for sure this is supported yet on Cloudflare Pages without somehow building in Cron Triggers in a worker. Looks like the workers preset is required when deploying. Some context: https://nitro.unjs.io/guide/tasks#platform-support I'd image your best bet for now is to build in a Worker schedule to call Nitro.
2 replies
NNuxt
Created by CedsTrash on 8/22/2024 in #❓・help
defineCachedEventHandler - set maxAge from environment variable
I often use a ternary here (everybody's absolute favorite).
maxAge: import.meta.dev ? config?.NITRO_CACHE_TTL : 1
maxAge: import.meta.dev ? config?.NITRO_CACHE_TTL : 1
typecast if needed:
Number(config?.NITRO_CACHE_TTL) || 1
Number(config?.NITRO_CACHE_TTL) || 1
Or you can use an arrow function
maxAge: () => { return some_logic_as_a_number }
maxAge: () => { return some_logic_as_a_number }
9 replies