Repository navigation
Conversation
kaankacar
commented
Mar 2, 2026
- Installed docusaurus-markdown-source-plugin to inject "Open Markdown" dropdown on every /docs/ page linking to currentPath + .md
- Added nginx location block to intercept .md URLs, strip the extension, and proxy to developers.stellar.org with Accept: text/markdown header
- Updated static/llms.txt to document the .md URL scheme and Accept header
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
There was a problem hiding this comment.
Pull request overview
Adds a “markdown view” pathway for Stellar developer docs so tooling/LLMs can retrieve page content as Markdown via a .md URL pattern (and documents the behavior in llms.txt).
Changes:
- Add
docusaurus-markdown-source-pluginand enable it in Docusaurus config. - Add an nginx rule to intercept
*.mdrequests and proxy to the corresponding non-.mdpath withAccept: text/markdown. - Update
static/llms.txtto describe the.mdURL scheme and header-based access.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
package.json |
Adds docusaurus-markdown-source-plugin dependency. |
yarn.lock |
Locks the new plugin and its dependency tree. |
docusaurus.config.ts |
Enables the markdown-source plugin in the Docusaurus plugins list. |
nginx/nginx.conf |
Proxies *.md requests to the corresponding page with Accept: text/markdown. |
static/llms.txt |
Documents the Markdown access pattern for consumers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| location ~* ^(.+)\.md$ { | ||
| resolver 1.1.1.1 valid=300s; | ||
| proxy_pass https://developers.stellar.org$1; | ||
| proxy_set_header Accept "text/markdown"; | ||
| proxy_set_header Host "developers.stellar.org"; |
There was a problem hiding this comment.
This regex location will be considered against all requests ending in .md (including under /assets/, /img/, etc.) and can override the existing prefix locations because they aren't marked ^~. To avoid unexpected proxying of static paths, scope the match to the intended docs routes (e.g., only /docs/...\.md$) and/or mark the static prefix locations as ^~ so they always win.
There was a problem hiding this comment.
scoped the regex to /docs/ only in a follow-up commit
| add_header 'Cache-Control' 'no-store' always; | ||
| } | ||
| location ~* ^(.+)\.md$ { | ||
| resolver 1.1.1.1 valid=300s; |
There was a problem hiding this comment.
resolver 1.1.1.1 hard-codes a public DNS resolver. This can break in restricted networks and may violate infra/security expectations; prefer using the environment's DNS (or a configurable internal resolver) and consider defining it at the http {} level to keep resolver policy centralized.
| resolver 1.1.1.1 valid=300s; |
There was a problem hiding this comment.
Resolver is required here, nginx won't resolve the hostname in proxy_pass without an explicit resolver directive. Removing it would break the proxy entirely. 1.1.1.1 is intentional for this public-facing deployment is what i see. @ElliotFriend thoughts?
| Each documentation page is available as clean markdown by appending `.md` to the URL | ||
| (e.g. `https://developers.stellar.org/docs/build/smart-contracts/overview.md`). | ||
| Alternatively, send an `Accept: text/markdown` request header to any page URL to receive markdown without modifying the URL. |
There was a problem hiding this comment.
llms.txt claims that sending Accept: text/markdown to any page URL returns markdown, but the nginx config in this repo only forces that header when a .md URL is requested (and otherwise serves static HTML). Either adjust this wording to match the actual behavior, or add server/CDN logic to honor Accept: text/markdown on normal page URLs.
There was a problem hiding this comment.
The accept: text/markdown behavior is handled by Cloudflare in front of this nginx. Tt already performs the HTML-to-markdown conversion when it sees that header, for any page URL. The nginx config in this repo only needs to handle the .md URL scheme (which it does by stripping .md and setting the header before passing to Cloudflare)
2 similar comments
1 similar comment
- Install docusaurus-markdown-source-plugin (v2.2.4) to inject "Open Markdown" dropdown on every /docs/ page and generate static .md files at build time for all .md and .mdx source pages - Update static/llms.txt to document the .md URL scheme and list all pages with .md URLs, including new Building with AI page
7488704 to
cffb2be
Compare
1 similar comment
|
Hey @ElliotFriend , In line with our last conversation I revised the approach to solely rely on the plugin and dropped the nginx proxy block entirely. The .md files are now generated statically at build time and served directly from disk. |
- main migrated yarn -> pnpm; resolve the yarn.lock modify/delete conflict by removing yarn.lock and adding the plugin to pnpm-lock.yaml - bump docusaurus-markdown-source-plugin floor ^2.0.1 -> ^2.2.4 (first version with .mdx source support); lock resolves to 2.2.5
The markdown-source plugin emits .md twins of docs pages but leaves intra-doc links pointing at source .mdx paths, which 404 when followed (only the .md twin is served). Add a postbuild step that rewrites those links to their .md twin — inside generated build/**/*.md only. - scripts/rewrite_md_links.mjs: filesystem-verified rewrite that only changes a link when the target .md twin actually exists, so it can never introduce a broken link. Handles the plugin's README->parent collapse and section-index depth via a per-file resolution-base vote. Touches generated .md artifacts exclusively: never a source file, never HTML (verified byte-identical before/after). - package.json: wire it as the postbuild hook so it runs automatically after 'pnpm build' in CI and the Docker production build.
Switch the post-build link rewrite from relative paths (../../foo.md) to full canonical URLs (https://developers.stellar.org/docs/foo.md) so the .md twins are self-contained for agents/LLMs and consistent with static/llms.txt. Origin and baseUrl are read from docusaurus.config.ts (single source of truth). Still output-only (HTML verified byte-identical) and idempotent — full-URL links are skipped as external on re-runs.
…llar#2289) * feat: serve pages as markdown and update llms.txt (stellar#2249) - Install docusaurus-markdown-source-plugin (v2.2.4) to inject "Open Markdown" dropdown on every /docs/ page and generate static .md files at build time for all .md and .mdx source pages - Update static/llms.txt to document the .md URL scheme and list all pages with .md URLs, including new Building with AI page * trigger preview rebuild * Rewrite intra-doc links to .md in generated markdown twins The markdown-source plugin emits .md twins of docs pages but leaves intra-doc links pointing at source .mdx paths, which 404 when followed (only the .md twin is served). Add a postbuild step that rewrites those links to their .md twin — inside generated build/**/*.md only. - scripts/rewrite_md_links.mjs: filesystem-verified rewrite that only changes a link when the target .md twin actually exists, so it can never introduce a broken link. Handles the plugin's README->parent collapse and section-index depth via a per-file resolution-base vote. Touches generated .md artifacts exclusively: never a source file, never HTML (verified byte-identical before/after). - package.json: wire it as the postbuild hook so it runs automatically after 'pnpm build' in CI and the Docker production build. * Emit full canonical URLs for rewritten markdown links Switch the post-build link rewrite from relative paths (../../foo.md) to full canonical URLs (https://developers.stellar.org/docs/foo.md) so the .md twins are self-contained for agents/LLMs and consistent with static/llms.txt. Origin and baseUrl are read from docusaurus.config.ts (single source of truth). Still output-only (HTML verified byte-identical) and idempotent — full-URL links are skipped as external on re-runs.