MDX.org.ai
Executable CodemdxeStyling

Content Formats

Extension-based content negotiation

Content Formats

The @mdxe/hono runtime supports multiple output formats via file extensions.

Supported Formats

ExtensionContent-TypeDescription
.htmltext/htmlRendered HTML
.jsonapplication/jsonMDXLD document
.mdtext/markdownOriginal MDX source
.txttext/plainPlain text content
.xmlapplication/xmlXML representation

Usage

Append extension to any URL:

curl https://example.com/docs/getting-started.json
curl https://example.com/docs/getting-started.md

Accept Header

Alternatively use Accept headers:

curl -H "Accept: application/json" https://example.com/docs/getting-started

JSON Response

{
  "id": "https://example.com/docs/getting-started",
  "type": "Docs",
  "data": {
    "title": "Getting Started",
    "description": "Learn how to use the library"
  },
  "content": "# Getting Started..."
}

Programmatic Usage

import { formatResponse } from '@mdxe/hono/format'
 
app.get('/docs/:slug', (c) => {
  const doc = loadDocument(c.req.param('slug'))
  return formatResponse(c, doc)
})

On this page