ManUtopiK
ManUtopiK
NNuxt
Created by ManUtopiK on 7/16/2024 in #❓・help
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
NNuxt
Created by ManUtopiK on 4/25/2024 in #❓・help
How to check if a composable exists ?
Ah yes. Thanks for your tip. I will take a try...
9 replies
NNuxt
Created by Mark Brouch on 2/14/2024 in #❓・help
How do you add a directory of files to publicAssets at build time?
Yep, that's the point. Cool, isn't it ? I asked nothing, it was @Mark Brouch . I'm proposing a solution.
12 replies
NNuxt
Created by ManUtopiK on 4/25/2024 in #❓・help
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
NNuxt
Created by Mark Brouch on 2/14/2024 in #❓・help
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
NNuxt
Created by ManUtopiK on 4/25/2024 in #❓・help
How to check if a composable exists ?
I have a layer with some components shared between two apps. I want the behaviour of the components to be different on one app and use a composable if it presents.
9 replies
NNuxt
Created by Mark Brouch on 2/14/2024 in #❓・help
How do you add a directory of files to publicAssets at build time?
I do this in a nuxt module :
nuxt.hook('nitro:config', (nitroConfig) => {
nitroConfig.publicAssets ||= []
nitroConfig.publicAssets.push({
dir: 'path/to/folder',
baseURL: ROUTE_CLIENT,
maxAge: 60 * 60 * 24 * 365, // 1 year
})
})
nuxt.hook('nitro:config', (nitroConfig) => {
nitroConfig.publicAssets ||= []
nitroConfig.publicAssets.push({
dir: 'path/to/folder',
baseURL: ROUTE_CLIENT,
maxAge: 60 * 60 * 24 * 365, // 1 year
})
})
12 replies
NNuxt
Created by ManUtopiK on 4/25/2024 in #❓・help
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
NNuxt
Created by CopyPasta on 4/24/2024 in #❓・help
Is there any way to build custom js files?
If you're building a module, you can use nuxt-module-build to write this file. Here's an example :
// File build.config.ts
import { defineBuildConfig } from 'unbuild'

export default defineBuildConfig({
entries: [{
builder: 'mkdist',
input: './src/runtime/libs',
}],
stub: false,
})
// File build.config.ts
import { defineBuildConfig } from 'unbuild'

export default defineBuildConfig({
entries: [{
builder: 'mkdist',
input: './src/runtime/libs',
}],
stub: false,
})
2 replies