Skip to content

[docs-infra] Add Markdown Alternates#720

Draft
dav-is wants to merge 416 commits intomasterfrom
davis/add-markdown-version
Draft

[docs-infra] Add Markdown Alternates#720
dav-is wants to merge 416 commits intomasterfrom
davis/add-markdown-version

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
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Dec 9, 2025
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Dec 16, 2025
@oliviertassinari oliviertassinari temporarily deployed to davis/add-markdown-version - mui-tools-public PR #720 December 21, 2025 00:58 — with Render Destroyed
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Jan 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: out-of-date The pull request has merge conflicts and can't be merged. 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.

4 participants