-
-
Notifications
You must be signed in to change notification settings - Fork 657
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't override default plugins #1212
Comments
Looks like the doc is incorrect, you should provide an array of strings only export default defineNuxtConfig({
content: {
markdown: {
remarkPlugins: ['remark-emoji']
}
}
}) |
But in Content v1 you use a string array when you want to add plugins and a function when you want to override the default ones. I think that way makes more sense 🤔 |
I don't disagree, just telling you how the code is setup in case you want to unblock yourself. This issue should be closed only if the doc is updated or the functionality is supported |
thank you for bringing this topic up! I have struggled with the similar problem, description is here : https://github.com/nuxt/framework/discussions/5163 Not able to override After 11 days my question is not answered yet, so I will try to follow up on this problem in your topic instead :) |
If I'm correct, the current situation is like the following: While Nuxt Content v1 uses its own module option resolution logic (i.e. content/packages/content/lib/index.js Line 53 in 776e428
// https://github.com/nuxt/framework/blob/643641d4891e2dc0ca261b594acefe3d4c4ac5c7/packages/kit/src/module/define.ts#L33-L41
// `applyDefaults` would not be called in case of Nuxt Content v2
function getOptions (inlineOptions?: OptionsT, nuxt: Nuxt = useNuxt()) {
const configKey = definition.meta.configKey || definition.meta.name
const _defaults = definition.defaults instanceof Function ? definition.defaults(nuxt) : definition.defaults
let _options = defu(inlineOptions, nuxt.options[configKey], _defaults) as OptionsT
if (definition.schema) {
_options = applyDefaults(definition.schema, _options) as OptionsT
}
return Promise.resolve(_options)
} What @imlautaro wants to do can be achieved with @atinux Or, it's appreciated if someone points out that I don't understand the situation correctly and there is a way to achieve the goal. IMHO, |
@nozomuikuta In general for Nuxt, we cannot use However, modules like content can support this explicitly and apply defaults in the module body. This experience for module authors would be simpler later using (*) As a related note to the content module and related use cases, if the intended defaults behavior is overriding and not extending, instead of adding function complexity, they could add only when user options are not provided conditionally. So that users don't need a function to override and can simply pass an array. Another pattern would be using a KV object so that users can explicitly disable on of the built-in plugins. We use this for postcsss plugins options for example. |
Environment
Linux
v14.17.3
3.0.0-rc.3
[email protected]
vite
content
,modules
@nuxt/[email protected]
-
Reproduction
https://github.com/imlautaro/content-app
Describe the bug
When you try to override the remark plugins (following the instructions in the documentation), it returns an error.
ERROR Cannot start nuxt: (options.remarkPlugins || []).map is not a function
Additional context
No response
Logs
The text was updated successfully, but these errors were encountered: