Files
supabase/apps/design-system/content/docs/fragments/ai-tools.mdx
Alexis Aguilar d1dcb57bdf feat(www): use the shared AiTools component on www pages (#52186)
## Problem

Docs guides, docs troubleshooting pages, and knowledge base guides
render the shared `AiTools` component from `ui-patterns`. The marketing
site renders its own copy of the same actions in `MarkdownActions`, with
the same styles and links. A change to one doesn't reach the other.

Resolves
[DOCS-1505](https://linear.app/supabase/issue/DOCS-1505/use-the-shared-aitools-component-on-www-pages).

## Solution

Blog posts, customer stories, event pages, changelog entries, and
pricing render `AiTools` through a www wrapper, and `MarkdownActions` is
deleted. The wrapper sends `copy_as_markdown_clicked` and
`ask_ai_clicked` with each page's type, as `MarkdownActions` did.

- **Prefer on Google:** blog posts show the Prefer on Google link
through `AiTools`, and clicks send `preferred_source_clicked`. #52026
proposed adding the link through `MarkdownActions`. This PR adds it
through `AiTools` instead, and #52026 is closed. The link's URL is a
shared constant in `markdown-affordance.ts`, which the docs wrapper also
uses.
- **Horizontal layout:** `AiTools` has an `orientation` prop. Pricing
uses it to keep the actions in a row under the hero. The design system's
AI Tools page documents it.
- **Headings:** `AiTools` adds an "AI tools" heading:
  - Blog posts style it like the sidebar's On this page label.
- Pricing, customer stories, and event pages hide it visually, so they
look as they do on the live site. Screen readers still announce it as
the section's label.
- Changelog entries give AI tools its own sidebar section, like Change
type and Products. The Links section appears only when an entry links to
a GitHub discussion.

The changelog index keeps `ChangelogLlmMarkdownButton`. It's a split
button in the header toolbar, and `AiTools` is a list of links built for
sidebars.

## Preview links

Compare the before and afters (since there's a lot of examples here,
links are less visually busy than images in this case):

| Site | Live | Preview |
| ------------- |
--------------------------------------------------------------------------------------------------------------------
|
---------------------------------------------------------------------------------------------------------------------------------------------------------------
|
| WWW |
[/blog/give-your-supabase-app-its-own-mcp-server](https://supabase.com/blog/give-your-supabase-app-its-own-mcp-server)
|
[/blog/give-your-supabase-app-its-own-mcp-server](https://zone-www-dot-com-git-alexisa-docs-1505-supabase.vercel.app/blog/give-your-supabase-app-its-own-mcp-server)
|
| WWW | [/pricing](https://supabase.com/pricing) |
[/pricing](https://zone-www-dot-com-git-alexisa-docs-1505-supabase.vercel.app/pricing)
|
| WWW | [/customers/berriai](https://supabase.com/customers/berriai) |
[/customers/berriai](https://zone-www-dot-com-git-alexisa-docs-1505-supabase.vercel.app/customers/berriai)
|
| WWW |
[/events/agency-webinar-ai-prototyping-production](https://supabase.com/events/agency-webinar-ai-prototyping-production)
|
[/events/agency-webinar-ai-prototyping-production](https://zone-www-dot-com-git-alexisa-docs-1505-supabase.vercel.app/events/agency-webinar-ai-prototyping-production)
|
| WWW |
[/changelog/cbc-tls-ciphers-deprecated](https://supabase.com/changelog/cbc-tls-ciphers-deprecated)
|
[/changelog/cbc-tls-ciphers-deprecated](https://zone-www-dot-com-git-alexisa-docs-1505-supabase.vercel.app/changelog/cbc-tls-ciphers-deprecated)
|
| WWW |
[/changelog/17817-pgbouncer-and-ipv4-deprecation](https://supabase.com/changelog/17817-pgbouncer-and-ipv4-deprecation)
|
[/changelog/17817-pgbouncer-and-ipv4-deprecation](https://zone-www-dot-com-git-alexisa-docs-1505-supabase.vercel.app/changelog/17817-pgbouncer-and-ipv4-deprecation)
|
| Design system |
[/design-system/docs/fragments/ai-tools](https://supabase.com/design-system/docs/fragments/ai-tools)
|
[/design-system/docs/fragments/ai-tools](https://design-system-git-alexisa-docs-1505-supabase.vercel.app/design-system/docs/fragments/ai-tools)
|

## Review instructions

1. Open each live and preview link side by side.
2. On pricing, check that the actions sit in the same row under the
hero.
3. On the blog post, check that the "AI tools" heading matches the On
this page label.
4. On the blog post, check that Prefer on Google appears in the sidebar
and at the end of the post on mobile.
5. On both changelog entries, check that AI tools has its own sidebar
section. Links appears only on the pgbouncer entry, which links to a
GitHub discussion.
6. On each page, click Copy as Markdown, Ask ChatGPT, and Ask Claude. On
the blog post, also click Prefer on Google. In the browser's network
tab, check that each telemetry request includes the page's `pageType`.
7. On the design system page, check the Horizontal layout example.

## Checklist

Check all before review:

- [x] I have read
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
- [ ] If I wrote a new docs topic or edited an existing topic, I used
the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs
[style
guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide)
2026-10-27 18:35:40 -04:00

67 lines
4.4 KiB
Plaintext

---
title: AI Tools
description: Page actions that copy the current page as Markdown or open it in an AI assistant.
fragment: true
---
AI Tools renders a short list of page actions under an "AI tools" heading. Readers can copy the page as Markdown, or open ChatGPT or Claude with a prompt that points to the page URL. Two optional links connect readers to the AI agent setup guide and to Google's preferred sources setting.
Docs guides, docs troubleshooting pages, and knowledge base guides use AI Tools in their sidebars.
<ComponentPreview name="ai-tools-demo" peekCode wide />
## Usage
```tsx
import { AiTools } from 'ui-patterns/AiTools'
```
```tsx
<AiTools
pageUrl="https://supabase.com/docs/guides/getting-started"
markdownUrl="/docs/guides/getting-started.md"
markdownFallback={() => document.querySelector('article')?.innerHTML ?? ''}
/>
```
Pass the canonical page URL as `pageUrl`. The Ask ChatGPT and Ask Claude links include it in their prompt, so it must be publicly reachable.
Copy as Markdown fetches `markdownUrl`. If the response isn't OK, it copies the string that `markdownFallback` returns instead, such as the rendered article HTML.
## Examples
### Required props only
Without `agentSetupHref` and `preferredSourceHref`, AI Tools renders Copy as Markdown, Ask ChatGPT, and Ask Claude.
<ComponentPreview name="ai-tools-minimal" peekCode wide />
### Horizontal layout
Set `orientation="horizontal"` to show the actions in a row, such as under a page heading. To hide the "AI tools" heading visually, pass `titleClassName="sr-only"`. Screen readers still announce it as the section's label.
<ComponentPreview name="ai-tools-horizontal" peekCode wide />
## Analytics
AI Tools doesn't send telemetry. Each surface passes callbacks and sends its own events from them. For example, the docs wrapper in `apps/docs/components/AiTools.tsx` sends `copy_as_markdown_clicked` from `onMarkdownCopy` and `ask_ai_clicked` from `onAskAiClick`.
`onMarkdownCopy` fires only after the clipboard write succeeds.
## Props
| Prop | Type | Default | Description |
| ------------------------ | ---------------------------------------- | ------------ | --------------------------------------------------------------------------------- |
| `pageUrl` | `string` | — | Canonical URL of the page. Used in the Ask ChatGPT and Ask Claude prompts. |
| `markdownUrl` | `string` | — | URL of the page's Markdown version. Copy as Markdown fetches it. |
| `markdownFallback` | `() => string` | `undefined` | Returns the text to copy when `markdownUrl` doesn't return an OK response. |
| `agentSetupHref` | `string` | `undefined` | Shows the Connect your AI agent link when set. |
| `preferredSourceHref` | `string` | `undefined` | Shows the Prefer on Google link when set. |
| `onAgentSetupClick` | `() => void` | — | Fires when the Connect your AI agent link is clicked. |
| `onPreferredSourceClick` | `() => void` | — | Fires when the Prefer on Google link is clicked. |
| `onMarkdownCopy` | `() => void` | — | Fires after the page is copied to the clipboard. |
| `onAskAiClick` | `(agent: 'chatgpt' \| 'claude') => void` | — | Fires when an Ask link is clicked, with the assistant it opens. |
| `orientation` | `'vertical' \| 'horizontal'` | `'vertical'` | Stacks the actions in a column or shows them in a row. |
| `titleClassName` | `string` | — | Extra classes on the "AI tools" heading. Use it to match the surrounding sidebar. |
| `className` | `string` | — | Extra classes on the root `section`. |