Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/tidy-markdown-values.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@pmndrs/docs': patch
---

Resolve MDX scope values in Copy Page, page Markdown endpoints and llms-full.txt through a shared document renderer. Preserve Markdown structure and literal code, provide static representations of built-in components, and support consumer markdownComponents overrides for interactive content.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,30 @@ resolve while you edit. Any option from

</details>

## Markdown exports

**Copy Page**, **View as Markdown** (`/<page>.md`), and `llms-full.txt` use the same document renderer. MDX expressions resolve against `scope`, including values inside Markdown tables, JSX attributes and commands. Headings, tables, lists, links, images and code are serialized as Markdown. Formatting is normalized; the MDX files are never rewritten. Inline code and fenced examples remain literal, including their braces and JSX.

Built-in components have static representations: tabs include every panel, code blocks include their authored commands, Mermaid keeps its diagram source, and theme presets expose their declared values. Color previews expose their role or CSS value, without computing browser styles. Sandpack and live embeds provide a static notice or destination; contributor and backer lists provide links.

Custom server-renderable components use their rendered content, including async components. A client component that Next exposes as an opaque reference uses a notice and its authored children. Components that need browser APIs, providers, or a particular interactive state should supply a server-renderable alternative in `markdownComponents`:

```ts
import type { DocsConfig } from '@pmndrs/docs/src/config'
import { Example } from './docs/authoring/Example'
import example from './docs/authoring/Example.json'

export default {
components: { Example },
scope: { example },
markdownComponents: {
Example: ({ initialCount }: { initialCount: number }) => `Count: ${initialCount}`,
},
} satisfies DocsConfig
```

`markdownComponents` overrides both built-in and configured components for Markdown exports only. Keep these alternatives free of client dependencies, including nested client components. Exports describe the authored or initial state at build time; they do not capture a reader's selected tab, edited playground, or theme preferences. Unresolved expressions and rendering errors fail the export with the document path instead of returning raw MDX.

# Releasing

Every push to `main` redeploys [docs.pmnd.rs](https://docs.pmnd.rs) via [ci.yml](.github/workflows/ci.yml) — no [changeset](.changeset/) needed for that.
Expand Down
3 changes: 3 additions & 0 deletions docs.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ import type { DocsConfig } from './src/config'
export default {
components: { Example, ExampleTable },
scope: { example },
markdownComponents: {
Example: ({ initialCount }: { initialCount: number }) => `Count: ${initialCount}`,
},
} satisfies DocsConfig
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,9 @@
"prettier-plugin-organize-imports": "^4.3.0",
"prettier-plugin-tailwindcss": "^0.8.1",
"redis": "^6.3.0",
"rehype-parse": "^9.0.1",
"rehype-stringify": "^10.0.1",
"shadcn": "^4.21.4",
"storybook": "^10.6.2",
"unified": "^11.0.5",
"vite": "^8.3.4",
"vitest": "^5.0.4"
},
Expand All @@ -64,6 +62,7 @@
"commander": "^15.0.0",
"esbuild": "^0.28.2",
"gray-matter": "^4.0.3",
"hast-util-to-mdast": "^10.1.2",
"image-size": "^2.0.4",
"ink": "^8.0.0",
"lodash-es": "^4.18.1",
Expand All @@ -72,20 +71,26 @@
"material-theme-builder": "^5.2.1",
"mcp-handler": "^2.3.0",
"mermaid": "^12.1.0",
"micromark-core-commonmark": "^2.0.4",
"next": "^16.4.0",
"next-mdx-remote": "^6.0.0",
"next-themes": "^0.4.6",
"postcss": "^8.5.29",
"react": "^19.3.0",
"react-dom": "^19.3.0",
"rehype-github-alerts": "^4.2.0",
"rehype-parse": "^9.0.1",
"rehype-prism-plus": "^2.0.2",
"rehype-remark": "^10.0.1",
"remark-gfm": "^4.0.1",
"remark-parse": "^11.0.0",
"remark-stringify": "^11.0.0",
"sanitize-html": "^2.18.0",
"tailwind-merge": "^3.7.0",
"tailwindcss": "^4.3.3",
"tw-animate-css": "^1.4.0",
"typescript": "^6.0.3",
"unified": "^11.0.5",
"unist-util-visit": "^5.1.0",
"xmlbuilder2": "^4.0.3",
"zod": "^4.6.7"
Expand Down
133 changes: 127 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading