Skip to content
Discussion options

You must be logged in to vote

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:beforeParse is not a NitroRuntimeHooks key, so a Nitro plugin will not see it.

The shape you tried in nuxt.config.ts is the right direction:

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:

  • restart the dev server after adding/changing the hook
  • confirm the file path condition matches v3 paths (console.log(ctx.file.path) once)
  • make sure transformMarkdown() returns a string, not…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@AloisSeckar
Comment options

Answer selected by AloisSeckar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants