docs: add docusaurus-plugin-copy-page-button#6462
Conversation
👷 Deploy request for cypress-docs pending review.Visit the deploys page to approve it
|
|
|
Quick note: I used my agents to help generate this PR. Feel free to tag me (@portdeveloper) in this thread with any questions and I'll reply asap 🙏 |
|
Friendly nudge on this PR — happy to address any feedback if it'd help land it. The plugin recently shipped on react/react-native-website#5085 and continues to see adoption. Thanks for your time! |
|
@portdeveloper Cool, thanks for the suggestion, we'll have someone evaluate this soon. Thanks! |
|
@portdeveloper a couple of questions:
Testing this locally, I tried configuring both injection locations because auto-inject was not consistently rendering the copy button in the same location, leading to odd, unexpected behaviors. The The |
|
Thanks this is great feedback, will address them asap |
|
shipped all three requested features in 0.8.0, so you can bump and test.
tracking: every action now fires a placement: you found a real bug — under before v1: lock the options above + an SSR/swizzle mode that renders the button in static html so placement never depends on client injection (the real fix for the above; the migration is interim). happy to tweak any of it 🙏 |
|
hey @emilyrohrbough — following up on the three asks: 0.8.0 shipped all of them (the |
|
@portdeveloper Hey! Thanks for the bump. I missed your original response. I'll add this to my list to review today! |
| ], | ||
| require.resolve('docusaurus-plugin-image-zoom'), | ||
| require.resolve('./plugins/llm'), | ||
| 'docusaurus-plugin-copy-page-button', |
There was a problem hiding this comment.
| 'docusaurus-plugin-copy-page-button', | |
| [ | |
| "docusaurus-plugin-copy-page-button", | |
| { | |
| injectButton: false, | |
| }, | |
| ], |
There was a problem hiding this comment.
Then an we add this to cypress-documentation/src/theme/TOC/index.tsx so this is rendered nicely before the TOC. right now it's inject between the title & content
export default function TOCWrapper(props) {
return (
<>
+ <div style={{display: "flex", justifyContent: "flex-end"}}>
+ <CopyPageButton
+ enabledActions={['copy', 'view', 'claude', 'chatgpt']}
+ markdownUrl={(url) => {
+ const { protocol, hostname, port, pathname } = new URL(url);
+ const llmRoute = [
+ protocol,
+ '//',
+ hostname,
+ port ? `:${port}` : '',
+ '/llm/markdown/',
+ pathname,
+ '.md'
+ ].join('');
+ return llmRoute
+ }}
+ customStyles={{
+ button: { className: styles.copyPageButton }
+ }}
+ />
</div>
<h2 className="border-l border-gray-1000/[.07] dark:border-gray-900 my-0 pb-[12px] pl-[1.5rem] text-gray-700 font-medium uppercase text-[16px]">
Contents
</h2>
<TOC
{...props}
className={clsx(
props.className,
'table-of-contents__left-border pt-[.1rem] table-of-contents'
)}
/>
</>
)
}There was a problem hiding this comment.
And these styles should align the button with ours:
.copyPageButton {
background: transparent !important;
border-radius: 4px;
font-size: 0;
gap: 4px;
margin-bottom: 0;
padding: 8px;
height: 32px;
}
- disable auto-injection (injectButton: false) - render <CopyPageButton> above the TOC via the existing swizzle - point markdownUrl at the /llm/markdown/*.md routes - align styling with the docs theme
|
done — pushed all three:
one tweak to your markdownUrl={(pageUrl) => {
const {origin, pathname} = new URL(pageUrl)
const rel = pathname.replace(/^\/+/, '').replace(/\/+$/, '')
return `${origin}/llm/markdown/${rel ? `${rel}.md` : 'index.md'}`
}}built locally and the button renders before the TOC, styles match, and the open-in-LLM links resolve to your real |

Summary
https://github.com/portdeveloper/docusaurus-plugin-copy-page-button
docusaurus-plugin-copy-page-buttonto the docs dependenciesdocusaurus.config.jsWhy
Cypress docs include testing guides, API pages, and examples that developers often bring into AI tools. This adds a page-level copy/open button that exports the current page as clean markdown and includes one-click Open in ChatGPT, Claude, and Gemini actions.
I checked the repo for overlapping features before opening this. Cypress already publishes LLM-readable markdown exports under
/llmplusllms.txt. This PR is different: it adds a page-level UI action for copying or opening the current page directly from the docs page.The plugin has no runtime dependencies and uses peer dependencies for Docusaurus and React.
Validation
git diff --checkNot run locally: full docs build, due the dependency install/build footprint in this environment.
Note
Low Risk
Docs-only UI and dependency wiring; no changes to auth, APIs, or content generation beyond reusing existing LLM markdown URLs.
Overview
Adds
docusaurus-plugin-copy-page-buttonso readers can copy, view, or open the current doc page in ChatGPT or Claude from the table of contents sidebar.The plugin is registered with
injectButton: falseand the button is placed manually in the swizzledTOCtheme.markdownUrlpoints at the existing/llm/markdown/...paths from the site’s LLM export plugin, so actions reuse published markdown rather than a new export path. Minor CSS styles the control in the TOC header.Reviewed by Cursor Bugbot for commit e366f18. Bugbot is set up for automated code reviews on this repo. Configure here.