Skip to content

Copy as Markdown

The Copy as Markdown action fetches the page’s .md source and writes it to the clipboard. The user gets exactly what the markdown route serves — the raw markdown body by default, or flattened Markdown if you set renderMarkdown — without leaving the page.

  • Pasting docs context into an LLM chat that doesn’t have URL prefill.
  • Quoting an authoritative version of a page in a PR or issue.
  • Feeding markdown into local tooling (note-taking apps, scripts, etc.).

copyMarkdown is on by default. To disable it:

starlightLlmActions({
actions: {
copyMarkdown: false,
},
})

When disabled, the action is removed from the dropdown.

The action runs entirely in the browser:

  1. The dropdown item resolves the page’s markdown URL using markdownUrl (default /{slug}.md).
  2. A fetch() request retrieves the markdown.
  3. The response body is written to the clipboard via the Async Clipboard API.

If the user’s browser blocks clipboard writes (e.g. on http:// origins without explicit permission), the action falls back to selecting the markdown into a hidden textarea and using document.execCommand('copy').

Copy as Markdown only appears on pages that have a Markdown route to fetch. A page outside every collection named in collections gets no .md file, so the item is dropped rather than fetching a 404. View as Markdown goes with it; the Open in… providers stay, falling back to the page’s own URL.

The action copies whatever the markdown route serves. To change the copied content, point markdownUrl at a different route:

starlightLlmActions({
markdownUrl: '/raw/{slug}.txt',
injectRoute: false, // your route already serves the content
})

See markdownUrl and injectRoute for the full options.

  • View as Markdown — opens the markdown URL in the browser instead of copying.
  • Open in… — sends the page (or a prompt referencing it) directly to an LLM.