Skip to content

[lexical-website] Feature: Server-rendered "Copy page" Markdown button#8570

Merged
etrepum merged 5 commits into
facebook:mainfrom
etrepum:claude/brave-hawking-AO2fx
May 27, 2026
Merged

[lexical-website] Feature: Server-rendered "Copy page" Markdown button#8570
etrepum merged 5 commits into
facebook:mainfrom
etrepum:claude/brave-hawking-AO2fx

Conversation

@etrepum
Copy link
Copy Markdown
Collaborator

@etrepum etrepum commented May 26, 2026

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

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.
@vercel
Copy link
Copy Markdown

vercel Bot commented May 26, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lexical Ready Ready Preview, Comment May 26, 2026 8:35pm
lexical-playground Ready Ready Preview, Comment May 26, 2026 8:35pm

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label May 26, 2026
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.
@etrepum etrepum added this pull request to the merge queue May 27, 2026
Merged via the queue into facebook:main with commit 1c7fc79 May 27, 2026
35 of 36 checks passed
@etrepum etrepum deleted the claude/brave-hawking-AO2fx branch May 27, 2026 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants