-
Notifications
You must be signed in to change notification settings - Fork 582
Add .md extension support for documentation pages #899
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- Add rewrite rule in next.config.js for *.md -> /api/markdown/* - Create middleware to handle Accept: text/markdown header - Create API route that fetches rendered HTML and converts to markdown - Use unified ecosystem (rehype-parse, rehype-remark, remark-gfm) - Extract main content via [data-algolia-page-scope] selector - Tables, code blocks, and links properly converted to GFM markdown
- Remove [data-algolia-lvl0] hidden elements (e.g., 'Components', 'Guides') - Fix remarkStringify strong option: use '*' instead of '**' (library doubles it)
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
1ba4d2d to
7aad014
Compare
components/PropsTable.tsx
Outdated
| <AccessibleIcon.Root label="Prop description"> | ||
| <InfoCircledIcon /> | ||
| </AccessibleIcon.Root> | ||
| <InfoCircledIcon aria-hidden="true" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the change here? Isn't this what AccessibleIcon already does for us? Markup on the site looks right to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Claude doing claude things, just changed it back.
Summary
Adds support for accessing documentation pages as markdown by appending
.mdto the URL or using theAccept: text/markdownheader. This is useful for AI agents and tools that need to consume documentation in a clean, structured format.How it works
.mdextension (e.g.,/themes/docs/components/button.md)Accept: text/markdownheaderThe implementation:
[data-algolia-page-scope])Filtering
Elements can be excluded from markdown output by adding the
data-md-excludeattribute. Currently used for:Files changed
next.config.js- Added rewrite rule for.mdextensionmiddleware.ts- AddedAccept: text/markdownheader handlingpages/api/markdown/[...path].ts- API route for HTML → Markdown conversioncomponents/CodeBlock.tsx- Addeddata-md-excludeto live previewscomponents/PropsTable.tsx- Addeddata-md-excludeto visually-hidden elementspackage.json- Added dependencies (rehype-remark, remark-stringify, remark-gfm, hast-util-select, oxfmt)