[lexical-website] Feature: Server-rendered "Copy page" Markdown button#8570
Merged
Conversation
Adds an in-repo "Copy page" button to documentation pages (Copy / View as Markdown / Open in ChatGPT, Claude, Perplexity, Gemini). The button is rendered server-side in a persistent right-hand column on every doc page so it never flashes in after hydration and stays in a consistent location even on pages without a table of contents. A build-time plugin emits a clean Markdown copy of each doc page under /llms/<path>.md so the actions use real Markdown instead of scraping the DOM on the client. A webpack alias dedupes @docusaurus/plugin-content-docs so the swizzled DocItem/Layout shares the DocProvider context with theme-classic.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Left-align the button to match the previous client-side placement, and make the "Open in ChatGPT/Claude/Perplexity/Gemini" actions plain anchors instead of window.open() calls, which were being silently swallowed by popup blockers. The absolute Markdown URL handed to AI tools now defaults to the configured Docusaurus site URL (stable for SSR/hydration) and reconciles to the live window origin on the client via useSyncExternalStore, so links are correct on production, preview, and local builds.
…ndency Replaces the webpack resolve.alias workaround with the idiomatic fix: declare @docusaurus/plugin-content-docs as a direct dependency of the site. Because the website swizzles theme-classic components that import its client entry, pnpm otherwise resolved a separate peer-variant copy for src/ than the one theme-classic's DocProvider uses, giving two React contexts and a ReactContextError from useDoc() during SSG. With the direct dependency both resolve the same copy, so the alias is no longer needed.
…page menu Gates the "Open in ChatGPT/Claude/Perplexity/Gemini" links behind a disabled ENABLE_AI_TOOL_LINKS flag, leaving the menu with just "Copy as Markdown" and "View as Markdown". The assistants tend to hallucinate having read the linked Markdown rather than actually fetching it; the link handlers are kept so they can be re-enabled by flipping the flag.
Index routes whose permalink ends in a slash (e.g. /docs/api/) produced a broken Markdown link like /llms/docs/api/.md because the button kept the trailing slash while the build-time plugin stripped it. Both sides now share a single relativeMarkdownPath helper, so the generated file path and the linked URL can no longer drift. Verified every doc route resolves to an existing Markdown file.
zurfyx
approved these changes
May 27, 2026
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.
Description
Adds an in-repo "Copy page" button to documentation pages (Copy / View as Markdown). The button is rendered server-side in a persistent right-hand column on every doc page so it never flashes in after hydration and stays in a consistent location even on pages without a table of contents.
A build-time plugin emits a clean Markdown copy of each doc page under /llms/.md so the actions use real Markdown instead of scraping the DOM on the client. A webpack alias dedupes @docusaurus/plugin-content-docs so the swizzled DocItem/Layout shares the DocProvider context with theme-classic.
The Open in ChatGPT, Claude, Perplexity, Gemini options have been hidden and disabled for now as it seems that the vercel config and/or these providers are ignoring the actual URLs and just hallucinating.
Closes #8568
Test plan
QA of built doc site