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 the raw markdown body — the same content served by the markdown route — 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').

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.