mirror of
https://github.com/supabase/supabase.git
synced 2026-12-06 08:29:01 +00:00
## I have read the [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) file. YES ## What kind of change does this PR introduce? Feature, bug fix. Part 4 of 6 in a stack that splits the library redesign into reviewable pieces. ## What is the current behavior? `BlockItem` renders the Open in v0 button, and `BlockItem` sits inside the Installation section — so the button appears partway down the page. On guides that install a client first it appears twice, once for the client and once for the block, and the MDX opts the extra one out with `showOpenInV0={false}`. So the page's markup already knows which registry item v0 should open. Only the component using it is in the wrong place. ## What is the new behavior? Velite reads that same signal at build time and records the item on the document, so the page header renders one icon button beside the framework selector, above the fold. `BlockItem` is left rendering only the install command. Guides with no installable item — the getting-started pages, the TanStack DB generator, and the starters — get no button. Guides that install a client first resolve to the block, not the client. ## Additional context 63 of 73 documents resolve to a registry item; the 10 that don't are exactly the ones that should have no button. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Documentation pages now display an “Open in v0” button when supported. * The button uses a compact, icon-only design alongside the framework selector. * **Improvements** * The applicable v0 destination is determined automatically from documentation content. * The page-level action replaces individual block-level v0 buttons, providing a more consistent experience. * The button includes an accessible label and appears only for documentation with a supported v0 destination. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com> Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com>
38 lines
1.3 KiB
TypeScript
38 lines
1.3 KiB
TypeScript
import { Button } from 'ui'
|
|
|
|
import { cn } from '@/lib/utils'
|
|
|
|
function V0Logo() {
|
|
return (
|
|
<svg viewBox="0 0 40 20" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
<path
|
|
d="M23.3919 0H32.9188C36.7819 0 39.9136 3.13165 39.9136 6.99475V16.0805H36.0006V6.99475C36.0006 6.90167 35.9969 6.80925 35.9898 6.71766L26.4628 16.079C26.4949 16.08 26.5272 16.0805 26.5595 16.0805H36.0006V19.7762H26.5595C22.6964 19.7762 19.4788 16.6139 19.4788 12.7508V3.68923H23.3919V12.7508C23.3919 12.9253 23.4054 13.0977 23.4316 13.2668L33.1682 3.6995C33.0861 3.6927 33.003 3.68923 32.9188 3.68923H23.3919V0Z"
|
|
fill="currentColor"
|
|
/>
|
|
<path
|
|
d="M13.7688 19.0956L0 3.68759H5.53933L13.6231 12.7337V3.68759H17.7535V17.5746C17.7535 19.6705 15.1654 20.6584 13.7688 19.0956Z"
|
|
fill="currentColor"
|
|
/>
|
|
</svg>
|
|
)
|
|
}
|
|
|
|
export function OpenInV0Button({ name, className }: { name: string; className?: string }) {
|
|
return (
|
|
<Button
|
|
asChild
|
|
variant="default"
|
|
size="medium"
|
|
className={cn('w-[38px] rounded-full px-0', className)}
|
|
icon={<V0Logo />}
|
|
>
|
|
<a
|
|
href={`https://v0.dev/chat/api/open?url=https://supabase.com${process.env.NEXT_PUBLIC_BASE_PATH ?? ''}/r/${name}.json`}
|
|
target="_blank"
|
|
rel="noreferrer"
|
|
aria-label="Open in v0"
|
|
/>
|
|
</Button>
|
|
)
|
|
}
|