Files
supabase/apps/docs/components/ContentListings/ContentListings.client.tsx
T
Nik RichersandNik Richers 0405b31b26 docs: re-publish Multigres Private Alpha docs — merge on October 2, 2026 (#50664)
## I have read the CONTRIBUTING.md file.

YES

## What kind of change does this PR introduce?

Re-add. Reapplies the Multigres Private Alpha docs section removed in
#50662, ready to merge once Sugu gives the go-ahead. Do not merge until
then.

Linear: MUL-1621 (follow-up to MUL-452).

## What is the current behavior?

Multigres docs section is down (per #50662): no overview/compatibility
pages, no sidebar entry, no features-table row, no "What you get" cards.

## What is the new behavior?

Exact reapply of #49020 (with Multigres marked Private Alpha): overview
guide at `/docs/guides/database/multigres`, compatibility stub, Database
sidebar entry, features-table row, "What you get" cards, and the
`ContentListings` optional-`href` support they rely on.

Base branch is the revert PR (#50662) so the diff here is legible now;
retarget to `master` once #50662 merges.

## Additional context

- `pnpm --filter docs exec vitest run lib/content-listings.test.ts` — 22
passed
- Blocked on Sugu's go-ahead — `do-not-merge` label applied

---------

Co-authored-by: Nik Richers <nik@validmind.ai>
2026-10-02 09:18:25 -07:00

164 lines
5.4 KiB
TypeScript

'use client'
import type { ContentListingGroup, ContentListingItem } from '~/lib/content-listings.schema'
import {
filterContentListingItems,
getContentListingById,
getContentListingGroupLabel,
isExternalContentListingHref,
} from '~/lib/content-listings.utils'
import { useSendTelemetryEvent } from '~/lib/telemetry'
import Link from 'next/link'
import { useCallback, useMemo } from 'react'
import ReactMarkdown from 'react-markdown'
import { Badge, Heading } from 'ui'
import { GlassPanel } from 'ui-patterns/GlassPanel'
import { resolveContentListingIcon } from './iconChip'
const GRID_ITEM_CLASS = {
// Stay 2-up until xl (~1280px) so cards aren't cramped beside the docs sidebar.
2: 'col-span-12 md:col-span-6',
3: 'col-span-12 md:col-span-6 xl:col-span-4',
4: 'col-span-12 md:col-span-6 xl:col-span-3',
} as const
function useContentListingClickHandler(group: ContentListingGroup) {
const sendTelemetryEvent = useSendTelemetryEvent()
const groupLabel = getContentListingGroupLabel(group)
const trackClick = useCallback(
(item: ContentListingItem) => {
if (!item.href) return
sendTelemetryEvent({
action: 'docs_content_listing_clicked',
properties: {
targetPath: item.href,
linkTitle: item.title,
...(groupLabel ? { groupTitle: groupLabel } : {}),
listingId: group.id,
},
})
},
[sendTelemetryEvent, group.id, groupLabel]
)
return { trackClick }
}
function ContentListingGroupHeading({ group }: { group: ContentListingGroup }) {
if (!group.heading) return null
return <Heading tag={group.headingLevel ?? 'h2'}>{group.heading}</Heading>
}
function ContentListingsGroup({ group }: { group: ContentListingGroup }) {
const { trackClick } = useContentListingClickHandler(group)
const items = useMemo(() => filterContentListingItems(group.items), [group.items])
const isGrid = group.type === 'grid'
const listClassName = isGrid ? 'grid md:grid-cols-12 gap-4' : 'list-disc pl-6 space-y-2'
const gridItemClassName = isGrid ? GRID_ITEM_CLASS[group.columns ?? 3] : undefined
if (!items.length) return null
// Heading stays outside `not-prose` so it inherits the surrounding MDX prose
// typography. The list itself opts out so its explicit Tailwind layout wins.
return (
<section className="space-y-4">
<ContentListingGroupHeading group={group} />
<div className="not-prose space-y-4">
{group.description && (
<div className="text-foreground-light [&_a]:text-foreground [&_a]:underline [&_p]:m-0">
<ReactMarkdown>{group.description}</ReactMarkdown>
</div>
)}
<ul className={listClassName}>
{items.map((item) => {
const key = `${group.id}-${item.href ?? item.title}`
const panel = (
<GlassPanel
title={item.title}
icon={resolveContentListingIcon(item.icon)}
hasLightIcon={item.hasLightIcon ?? typeof item.icon === 'string'}
className={item.href ? undefined : 'cursor-default'}
badge={
item.badge && item.badgePosition !== 'below' ? (
<Badge variant="success">{item.badge}</Badge>
) : undefined
}
>
{item.badge && item.badgePosition === 'below' && (
<Badge variant="success" className="mb-3 block w-fit">
{item.badge}
</Badge>
)}
{item.subtitle && (
<span className="mb-2 block text-tertiary-foreground">{item.subtitle}</span>
)}
{item.description}
</GlassPanel>
)
const listContent = (
<>
<strong>{item.title}</strong>: {item.description}
</>
)
if (!item.href) {
return (
<li key={key} className={gridItemClassName}>
{isGrid ? panel : listContent}
</li>
)
}
const external = isExternalContentListingHref(item.href)
if (isGrid) {
return (
<li key={key} className={gridItemClassName}>
<Link
href={item.href}
passHref
className="block h-full"
onClick={() => trackClick(item)}
target={external ? '_blank' : undefined}
rel={external ? 'noopener noreferrer' : undefined}
>
{panel}
</Link>
</li>
)
}
return (
<li key={key}>
<Link
href={item.href}
onClick={() => trackClick(item)}
target={external ? '_blank' : undefined}
rel={external ? 'noopener noreferrer' : undefined}
>
{listContent}
</Link>
</li>
)
})}
</ul>
</div>
</section>
)
}
export function ContentListings({ id }: { id: string }) {
const group = getContentListingById(id)
if (!group || !filterContentListingItems(group.items).length) return null
return (
<div className="my-10 space-y-10">
<ContentListingsGroup group={group} />
</div>
)
}