Skip to content

Copy page button - #1134

Open
brandonleekramer wants to merge 3 commits into
mainfrom
copy-page-button
Open

brandonleekramer wants to merge 3 commits into
mainfrom
copy-page-button

Conversation

@brandonleekramer

Copy link
Copy Markdown
Member

Adds a Copy page button to the top of every docs page. It copies the page as Markdown so readers can paste it into an LLM. This reworks #1089 by @PaulieB14 to use the Graph Design System (GDS) and fix bugs found in review. PaulieB14 is credited as co-author on both commits.

Supersedes #1089.

What it does

  • A small GDS button sits at the end of the reading-time row, above the page title.
  • On click, it loads the page's source file from GitHub (the same file "Edit on GitHub" opens) and copies it as Markdown:
    • The frontmatter is replaced by the page title as a heading and a Source: line with the page's URL.
    • MDX import lines are removed. Lines inside code blocks are kept.
  • The source starts loading when the button is hovered or focused, so the copy is usually instant.
  • "Copied as Markdown" appears only once the page is on the clipboard, with the copy icon switching to a check. If loading or copying fails, the button says "Couldn't copy this page".
  • New labels: global.page.copy, global.page.copied and global.page.copyFailed in en/global.json.

Changes from #1089

  • GDS components. Built from ExperimentalButton, Tooltip and the CopyInteractive icon in @edgeandnode/gds, the version the site already uses. This replaces raw <button>s, a hand-built dropdown, inline SVG icons and one-off Tailwind classes. ExperimentalCopyButton isn't used directly because it shows "Copied" before an async copy finishes, so it can't report a failure.
  • One action, no dropdown. "View as Markdown" opened the same GitHub file as "Edit on GitHub", and @edgeandnode/gds v6 has no dropdown menu with a trigger.
  • At the top of the page, not the footer. Readers decide to paste a page into an LLM before reading it.
  • Code examples are kept. feat: add "Copy page" button for LLMs #1089 removed every line starting with import, including inside code blocks. 8 pages lost example code this way, including 21 lines on graph-ts/api.mdx.
  • Pages from other repos work. Their GitHub links use /tree/, which feat: add "Copy page" button for LLMs #1089 turned into a 404 address. On the graph-ts changelog, it copied the 404 page and still said "Copied!".
  • No false confirmations. Failed loads and clipboard errors show an error message instead of "Copied".
  • Safari support. Safari blocks clipboard writes that happen after waiting for a download, so the copy hands the pending text to ClipboardItem. Other browsers fall back to writeText.
  • No unrelated changes. The escaped backticks feat: add "Copy page" button for LLMs #1089 added to a comment in content.tsx are left out.

Files

  • website/src/components/CopyPageButton.tsx: the new component.
  • website/src/components/index.ts: exports it.
  • website/src/layout/templates/default/content.tsx: adds the button to the page header.
  • website/src/pages/en/global.json: the three labels.

Testing done

  • tsc, eslint --max-warnings 0 and prettier --check pass.
  • The Markdown output was checked against real pages:
    • Code-block imports are kept (21 of 21

brandonleekramer and others added 2 commits November 20, 2026 12:43
Reworks #1089 to use ExperimentalCopyButton.

Co-authored-by: PaulieB14 <barba334@gmail.com>
Co-authored-by: PaulieB14 <barba334@gmail.com>

@itsjerryokolo itsjerryokolo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified that Copy page picks up the new page after navigation. All four checks passed. Looks good to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants