Nitro Api

Nitro Hooks

Last updated by
Harlan Wilton
in initial commit.

'ai-ready:markdown'

Type: (context: MarkdownContext) => void | Promise<void>

Called during HTML→Markdown conversion in the runtime middleware. Allows you to modify the markdown content before it's returned to the client.

Context:

interface MarkdownContext {
  html: string          // Original HTML content
  markdown: string      // Generated markdown (modify this)
  route: string         // Route being processed
  title: string         // Page title
  description: string   // Page description
  isPrerender: boolean  // Whether during prerendering
  event: H3Event        // H3 event object
}

Example: Add Footer

server/plugins/markdown-footer.ts
export default defineNitroPlugin((nitroApp) => {
  nitroApp.hooks.hook('ai-ready:markdown', async (context) => {
    // Add footer to all markdown
    context.markdown += '\n\n---\n*Generated with mdream*'
  })
})

'ai-ready:mdreamConfig'

Type: (config: HTMLToMarkdownOptions) => void | Promise<void>

Called before HTML→Markdown conversion. Allows you to modify the mdream configuration options.

Example: Custom Plugin

server/plugins/mdream-config.ts
export default defineNitroPlugin((nitroApp) => {
  nitroApp.hooks.hook('ai-ready:mdreamConfig', async (config) => {
    // Add custom mdream plugin
    config.plugins = config.plugins || []
    config.plugins.push(myCustomPlugin())
  })
})
Did this page help you?