Skip to content

Conversation

@dav-is
Copy link
Member

@dav-is dav-is commented Sep 18, 2025

For each page.mdx, we should generate a markdown alternate.

e.g. /app/components/checkbox/page.mdx will be availiable at /components/checkbox with a markdown alternate stored at /components/checkbox.md

To install, create app/[...markdownPath]/route.ts:

export * from '@mui/internal-docs-infra/markdownAlternatePage';

This route exports generateStaticParams with a list of all expected .md files.

Add to your build script in the docs package.json:

  "scripts": {
    "dev": "next dev --turbopack",
-   "build": "next build",
+   "build": "next build && docs-infra post-build",
    "start": "serve ./out"
  },

To publish this markdown, each page should add this to the head:

<link rel="alternate" type="text/markdown" href="/components/checkbox.md" title="Markdown" />

and this to HTTP headers so the alternate can be discovered using a HEAD request:

Link: </components/checkbox.md>; rel="alternate"; type="text/markdown"; title="Markdown"

A link should also be added somewhere directly in the page.

If the server is capable of Next.js rewrites, it should also support Accept: text/markdown and Accept: text/plain

module.exports = {
  async rewrites() {
    return {
      beforeFiles: [
        {
          source: '/:path*',
          has: [{ type: 'header', key: 'Accept', value: '^(?!text/html).*text/markdown.*$' }],
          destination: '/:path*.md',
        },
      ],
      afterFiles: [],
      fallback: [],
    }
  },
}

@dav-is dav-is removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Oct 14, 2025
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Nov 10, 2025
@dav-is dav-is removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Nov 10, 2025
Base automatically changed from davis/add-docs-infra-docs to master November 24, 2025 14:49
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Nov 24, 2025
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Nov 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: docs-infra Involves the docs-infra product (https://www.notion.so/mui-org/b9f676062eb94747b6768209f7751305).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants