Add Open in ChatGPT and Open in Claude page actions#4658
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Adds two external-link actions alongside the existing Copy for LLM and View as Markdown CTAs under the page title. Each opens the respective assistant in a new tab with a prompt prefilled to read the current page. - Capture the page URL client-side (window unavailable during SSR) - Render ChatGPT/Claude as anchors with OpenAI/Claude brand icons plus a trailing external-link icon - Normalize button vs. anchor height (line-height, box-sizing, font-family) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
5a6a69a to
49bc308
Compare
📖 Docs PR preview linksThis PR does not change any pages in /docs. If you make updates, links to the modified pages will appear here. |
The new pageUrl state shadowed a local of the same name inside handleCopyForLLM. Reuse the state value (added to the callback deps) instead of re-reading window.location.href. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
49bc308 to
57fba60
Compare
jsundai
left a comment
There was a problem hiding this comment.
Nice!! Will take a full look sometime today.
|
if it fails to get the Page URL, we should hide the buttons unless there is a valid URL. |
Addresses review feedback: the ChatGPT/Claude prompts were built from a client-side window.location.href captured in useEffect, which left the URL empty during SSR and the first render. Derive a canonical absolute URL from siteConfig.url + metadata.permalink instead, so the prompt is always valid with no effect, state, or empty-URL window. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Good call — fixed in 3e09dfc, though I went a slightly different route than disabling the buttons. Root cause: the prompt URL was built from Rather than guard/disable on an empty value, I removed the failure mode entirely: the URL is now derived synchronously from Docusaurus's own data — const { siteConfig } = useDocusaurusContext();
const pageUrl = `${siteConfig.url}${metadata.permalink}`;So it's a valid canonical URL during SSR, first paint, and every render — no Verified in the browser — the rendered links resolve to: |
Summary
Adds two new external-link actions alongside the existing Copy for LLM and View as Markdown CTAs under the docs page title:
chatgpt.comin a new tab with a prompt prefilled to read the current pageclaude.aiin a new tab with the same prefilled promptThe prompt sent to each assistant is:
Read <page-url> and answer questions about the content.Changes
src/components/LLMActions/LLMActions.tsxwindowis unavailable during SSR) and build encoded ChatGPT/Claude deep linksreact-icons/si) plus a trailing external-link icondata-analytics-*attributes as the existing actions (open-in-chatgpt/open-in-claude) so usage is tracked in Amplitudesrc/components/LLMActions/LLMActions.module.css<button>and<a>elements (line-height,box-sizing,font-family,text-decoration)externalIconstyleTesting
npm run start; all four actions render at a consistent height under the page title and the external links open the respective assistants with the page URL prefilled.🤖 Generated with Claude Code