ManUtopiK
Programmatically refresh nuxt-content generated pages ?
Here a file on how I refresh the data :
https://gist.github.com/ManUtopiK/84580cd8fd9e135eb5d5e1901403a4d4
It's very experimental. It doesn't handle assets.
I wonder If there is another way to do that ? Any idea ?
2 replies
How to check if a composable exists ?
Another use case I have for this.
I want to release a library and make it open source. This library contains several components with some text and I want to provide translation with i18n.
How to check in my components if i18n composable is here and translate text ? Or provide default EN text if there's no i18n composable ?
Of course, I don't want to ship i18n in my library.
9 replies
How do you add a directory of files to publicAssets at build time?
Sorry, I don't understand what you mean.
I use this alongside with nuxt-content and push the files of the content directory in the public directory, so every files (.md, .yaml...) are available at runtime.
With this, I can fetch the files at runtime, or access it just by adding extension to the route.
Let's say I have this content :
/content
my-file.md
So, I can navigate to the route https://example.com/my-file to display the page, or get the raw markdown content with https://example.com/my-file.md
It also works for sub path and any kind of files : .yaml, .json ...
12 replies
How to check if a composable exists ?
I reply a long time ago. First, thank you for your response. It looks fine but can serve my purpose.
In fact, I use nuxt layers. I want to check in a component of a layer if the composable exists. So, I can't rely on
path/to/myComposable
because the composable is outside the package.
Using const { myComposable } = await import('#imports')
break nuxt build if the composable doesn't exist.
Any other idea to do that ?9 replies