feat: Add markdown exports and a Copy as Markdown button - #738
Draft
developerjamiu wants to merge 2 commits into
Draft
feat: Add markdown exports and a Copy as Markdown button#738developerjamiu wants to merge 2 commits into
developerjamiu wants to merge 2 commits into
Conversation
developerjamiu
force-pushed
the
copy-page-as-markdown
branch
5 times, most recently
from
August 11, 2026 16:34
6880eaa to
9c0f63a
Compare
developerjamiu
marked this pull request as draft
August 11, 2026 17:02
developerjamiu
force-pushed
the
copy-page-as-markdown
branch
from
August 12, 2026 15:26
9c0f63a to
309efe3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a markdown export of the docs plus a "Copy as Markdown" button, so users can paste any page into an LLM or coding agent with its structure intact. Inspired by the Stripe docs copy-page control.
What ships
Markdown endpoints (commit 1). Every page the site serves gets a clean markdown version at its page URL with
.mdappended (/concepts/caching.md), across both docs instances and all versions: about 1,630 files, 9.8 MB. Each file starts with the page title as H1 and its canonical URL. MDX partial imports are inlined (the CLI reference pages), Tabs unwrap to labeled sections, video embeds become links, snipsync markers are stripped, code fences keep their language tags, mermaid diagrams stay as fenced blocks, and relative links are rewritten to absolute URLs. Generated by a local plugin (plugins/markdown-export), which also serves the files on the dev server sonpm startbehaves like production.Discovery files.
llms.txtat the site root (llmstxt.org format) indexes the current stable framework docs and the Cloud docs, withllms-full.txt(925 KB) andcloud/llms-full.txt(151 KB) as single-file versions. Stable is derived fromversions.json, so version cuts need no changes here. Renamed pages get a one-line "moved to" stub generated from the client-redirects config, so previously copied.mdURLs keep working.Copy button (commit 2). A "Copy as Markdown" button above every doc page's title, beside the "Version: X" badge and styled with the same infima badge classes so the pills match (a
DocVersionBadgewrapper; on pages without a version badge, like Cloud, the button stands alone). It fetches the page's.mdand writes it to the clipboard with the ClipboardItem-promise pattern (Safari invalidates clipboard permission across an awaited fetch), guards against HTML responses, announces state changes to screen readers, and fires a guardedcopy_page_markdowngtag event. Each doc page also emits<link rel="alternate" type="text/markdown">for agent discovery.Supporting changes
static/robots.txtdisallows*.mdso the duplicates stay out of search indexes (GitHub Pages allows no headers, so robots.txt is the only lever, and it must ship together with the files).llms.txtstays crawlable on purpose.deploy.ymlnow copies.nojekyllexplicitly. Thecp -r src/build/*glob skips dotfiles, so the live file only survived by accident; without it, Jekyll would process the.mdfiles instead of serving them.util/verify_markdown_export.jschecks the export after every build (every sitemap route has a non-empty.md, no JSX/import/snipsync residue, H1 + canonical URL shape, all llms.txt links resolve to stable-only targets, redirect stubs exist, the alternate link tag renders). Wired into the test-build workflow.Approach notes
An existing plugin (
@signalwire/docusaurus-plugin-llms-txt) was evaluated first: it handled partials, versions, and route mapping well, but it converts the rendered HTML, which drops mermaid diagrams entirely (they render client-side, so the source is not in the HTML) and strips every code-fence language tag. For a corpus built ondart/yamlfences that was disqualifying, hence the source-based local plugin.Known gap, accepted: the framework CLI reference only exists in the next version, so the stable-built llms files have no CLI content until the next version cut. The per-page files at
/next/concepts/cli/...mdcover it in the meantime.Verified
.md, all 3,253 internal links inside the exports resolve, all llms links and canonical lines resolve, 22 redirect stubs match the 22 redirect sources in the config..mdwithtext/markdown(fetch + copy path works in dev).Generated 1631 markdown pages ... in 4.1s).Manual QA remaining
.mdreturns 200 with a text content type; robots.txt live; Algolia index picks up no.mdrecords after the next crawl.