How to use hooks to augment md content in v3? #3250
-
|
In Nuxt Content v2 I had Nitro plugin like this: How can I use this in v3? IDE says: "Argument of type '"content:file:beforeParse"' is not assignable to parameter of type 'HookKeys'." and the augmentation is not happening. Based on (very brief) documentation page I tried to add following into Did I figured out the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
In v3 this hook should be registered on the Nuxt/content side, not as a Nitro runtime hook. The TypeScript error is the clue: The shape you tried in export default defineNuxtConfig({
hooks: {
'content:file:beforeParse'(ctx) {
if (ctx.file.path.endsWith('.md')) {
ctx.file.body = transformMarkdown(ctx.file.body)
}
},
},
})Things I would check:
For a reusable Nuxt module, register it with |
Beta Was this translation helpful? Give feedback.
In v3 this hook should be registered on the Nuxt/content side, not as a Nitro runtime hook. The TypeScript error is the clue:
content:file:beforeParseis not aNitroRuntimeHookskey, so a Nitro plugin will not see it.The shape you tried in
nuxt.config.tsis the right direction:Things I would check:
console.log(ctx.file.path)once)transformMarkdown()returns a string, not…