mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 07:29:16 +00:00
## Problem Many of the different versions of the frameworks are actually orphaned pages, meaning that no other pages link to them. ## Solution Adds a new component `OtherFrameworks` and includes it at the bottom of those component block pages. Seems to also be a usability win, since you might be switching at the top or bottom of the page. Not sure if parts of the design need work though. ## Preview links https://ui-library-git-kody-devrel-867-resolve-orphaned-ebe6f7-supabase.vercel.app/library/docs/tanstack/oauth-consent <img width="1024" height="670" alt="image" src="https://github.com/user-attachments/assets/77c89dae-9c80-4f1f-ab28-986581ecd1ae" />
45 lines
1.6 KiB
TypeScript
45 lines
1.6 KiB
TypeScript
import Link from 'next/link'
|
|
|
|
import { allDocs } from '@/.velite'
|
|
import { frameworkTitles } from '@/config/docs'
|
|
|
|
/**
|
|
* Static list of links to the other framework versions of a block. Rendered on the server so
|
|
* every version of a block is reachable from the page HTML, not only from the framework menu.
|
|
*/
|
|
export function OtherFrameworks({ slug }: { slug: string }) {
|
|
const [currentFramework, ...docPath] = slug.split('/')
|
|
const docName = docPath.join('/')
|
|
|
|
// Other versions are the docs with the same path under a different framework folder
|
|
const otherFrameworks = Object.keys(frameworkTitles).filter(
|
|
(framework) =>
|
|
framework !== currentFramework &&
|
|
allDocs.some((doc) => doc.slugAsParams === `${framework}/${docName}`)
|
|
)
|
|
|
|
if (!(currentFramework in frameworkTitles) || otherFrameworks.length === 0) {
|
|
return null
|
|
}
|
|
|
|
return (
|
|
<nav aria-labelledby="other-frameworks-heading" className="border-t py-8">
|
|
<h2 id="other-frameworks-heading" className="text-xs text-foreground-lighter">
|
|
Other frameworks
|
|
</h2>
|
|
<ul className="mt-3 flex flex-wrap gap-2">
|
|
{otherFrameworks.map((framework) => (
|
|
<li key={framework}>
|
|
<Link
|
|
href={`/docs/${framework}/${docName}`}
|
|
className="inline-flex h-7 items-center rounded-md border bg-surface-75 px-2 text-xs text-foreground-light transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
|
>
|
|
{frameworkTitles[framework]}
|
|
</Link>
|
|
</li>
|
|
))}
|
|
</ul>
|
|
</nav>
|
|
)
|
|
}
|