Guides

Markdown Conversion

Last updated by
Harlan Wilton
in feat: `contentSignal` module config.

Nuxt AI Ready uses mdream to convert HTML pages to AI-optimized markdown during prerendering and runtime.

Conversion Flow

Build-Time (Prerendering)

During nuxi generate or nuxi build --prerender:

  1. HTML processed via mdream extraction plugin (title, description, headings)
  2. Converted to markdown and chunked
  3. Written to bulk JSONL at /content.jsonl
  4. Full markdown served at .md routes
// Chunking config (reference)
const chunks = htmlToMarkdownSplitChunksStream(html, {
  headersToSplitOn: [TagIdMap.h1, TagIdMap.h2, TagIdMap.h3],
  chunkSize: 256,
  lengthFunction: estimateTokenCount,
})

Runtime

Requests with .md extension or Accept: text/markdown header trigger on-the-fly conversion with cache headers.

curl https://example.com/about.md
curl -H "Accept: text/markdown" https://example.com/about

Configuration

// Minimal example
aiReady: { mdreamOptions: { preset: 'minimal' } }

// Full config: /docs/ai-ready/api/config#mdreamoptions

Hooks

ai-ready:mdreamConfig

// Dynamic config based on route
nitroApp.hooks.hook('ai-ready:mdreamConfig', (options) => {
  if (options.origin?.includes('/blog/'))
    options.ignoreElements = [...(options.ignoreElements || []), '.author-bio']
})

// Full docs: /docs/ai-ready/nitro-api/nitro-hooks#ai-ready-mdreamconfig

ai-ready:markdown

// Post-process markdown output
nitroApp.hooks.hook('ai-ready:markdown', (context) => {
  context.markdown = `---\ntitle: ${context.title}\n---\n\n${context.markdown}`
})

// Full docs: /docs/ai-ready/nitro-api/nitro-hooks#ai-ready-markdown

Learn More

Did this page help you?