OpenInAI
Per-page dropdown that opens the current doc in ChatGPT, Claude, Perplexity, or Google AI Studio — plus a "Copy as Markdown" action for LLM prompts.
<OpenInAI> renders a small dropdown in the page header — the reader clicks it and gets four links (pre-filled with the current page URL) to ask their AI of choice, plus a “Copy as Markdown” action that writes [title](url) to the clipboard.
Publier can wire this into the page meta automatically; you only need to import and render it yourself when embedding in a custom layout or inline inside MDX.
Live demo
Click the button below to see the dropdown. Links open in a new tab with the current page’s URL pre-filled:
import { OpenInAI } from '@publier/shell/components';
<OpenInAI pageUrl="https://publier.net/docs/ui-components/open-in-ai" pageTitle="OpenInAI — Publier"/>In a custom layout
Pass Astro’s runtime URL and the frontmatter title:
---import { OpenInAI } from '@publier/shell/components';
const { frontmatter } = Astro.props;---
<OpenInAI pageUrl={Astro.url.href} pageTitle={frontmatter.title}/>What each action does
| Action | Result |
|---|---|
| ChatGPT | Opens chat.openai.com with the page URL pre-filled as the first message. |
| Claude | Opens claude.ai with the page URL as the starter prompt. |
| Perplexity | Opens perplexity.ai pre-queried with the page URL. |
| Google AI Studio | Opens Google’s AI Studio with the page URL. |
| Copy as Markdown | Writes [pageTitle](pageUrl) to the clipboard. Shows a 2-second “Copied!” confirmation. |
Props
| Prop | Type | Default | Description |
|---|---|---|---|
pageUrl | string | '' | Full URL of the current page. Passed to each AI tool as context. |
pageTitle | string | '' | Used in the “Copy as Markdown” action: writes [pageTitle](pageUrl). |
Behaviour
- External AI links open in a new tab (
target="_blank" rel="noopener noreferrer"). - Clipboard write is wrapped in a try/catch — non-HTTPS origins and denied permissions fail silently (no error banner).
- The dropdown closes on outside click via a document-level listener.
- Zero hydration cost until the trigger button is visible.
Accessibility
- The trigger is a real
<button>witharia-haspopup="menu"andaria-expanded. - Dropdown uses
role="menu"+role="menuitem"for screen readers. - Keyboard: Enter/Space opens; Escape closes.
Related
- Full-page AI chat experience → AskAi.
- LLM-friendly site-wide dump →
/llms.txtreference.