Add .md suffix support with static generation for raw MDX source#537
Add .md suffix support with static generation for raw MDX source#537
Conversation
Co-authored-by: abernier <76580+abernier@users.noreply.github.com>
…ming Co-authored-by: abernier <76580+abernier@users.noreply.github.com>
|
when pnpm run build: |
Co-authored-by: abernier <76580+abernier@users.noreply.github.com>
Fixed in commit 4b555a6. The issue was that Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
.md should also be statically generated @copilot |
Co-authored-by: abernier <76580+abernier@users.noreply.github.com>
Implemented in commit e11f167. Added static generation for
All Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot not only at build time, also when run dev |
# Start dev server
pnpm run dev
# Access raw MDX
curl http://localhost:3000/authoring/introduction.mdBoth dev mode (dynamic via proxy.ts) and build mode (static via generate-md-files.ts) are fully functional. |
Implementation Complete: Return Raw MDX Source for .md URLs
src/proxy.tsto intercept .md requests and return raw MDX source (dev mode)scripts/generate-md-files.tsfor static generation (build/export mode)next-build.shto generate static .md files during export buildsSummary
This PR adds support for accessing raw MDX source files by appending
.mdto any documentation URL, with full static generation support for both development and production/export modes.Changes Made:
src/proxy.ts- Uses Next.js 16's proxy feature to intercept requests ending with.mdand return raw MDX content with frontmatter as plain text (text/markdown) in development modescripts/generate-md-files.ts- Build-time script that generates static.mdfiles for all documentation pages, preserving frontmatter and contentnext-build.sh- Modified to run the generation script after Next.js build when in export mode, and temporarily moves proxy.ts during static export (since it requires server runtime)tsxdev dependency - Required to execute the TypeScript build scriptHow it Works:
Development Mode (with Next.js dev server):
/getting-started/introduction) → HTML page with full layout.mdsuffix (e.g.,/getting-started/introduction.md) → Raw MDX source with frontmatter (handled by proxy.ts at runtime)Production/Export Mode (static files for GitHub Pages):
.mdsuffix → Pre-generated static.mdfile with raw MDX sourceTesting:
✅ HTML pages render correctly
✅
.mdURLs return plain text MDX with propertext/markdowncontent-type in dev mode✅ Static
.mdfiles are generated during build for export mode✅ Static
.mdfiles contain correct frontmatter and content✅ Linting and formatting checks passed
✅ Code review feedback addressed
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.