mirror of
https://github.com/supabase/supabase.git
synced 2026-07-07 12:59:40 +08:00
* refactor(docs): turn auth error codes table into data file Take the Markdown error codes table and turn it into a data file instead. This makes it easy to parse and reuse in other places besides Markdown documents. * Update apps/docs/content/errorCodes/authErrorCodes.toml Co-authored-by: Terry Sutton <saltcod@gmail.com> --------- Co-authored-by: Terry Sutton <saltcod@gmail.com>
50 lines
1.5 KiB
TypeScript
50 lines
1.5 KiB
TypeScript
import Link from 'next/link'
|
|
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from 'ui'
|
|
import _errorCodes from '~/content/errorCodes/authErrorCodes.toml'
|
|
|
|
interface ErrorCodeDefinition {
|
|
description: string
|
|
references: Array<{ href: string; description: string }>
|
|
}
|
|
|
|
const errorCodes: Record<string, ErrorCodeDefinition> = _errorCodes
|
|
|
|
export function AuthErrorCodes() {
|
|
return (
|
|
<Table>
|
|
<TableHeader>
|
|
<TableRow>
|
|
<TableHead>Error code</TableHead>
|
|
<TableHead>Description</TableHead>
|
|
</TableRow>
|
|
</TableHeader>
|
|
<TableBody>
|
|
{Object.entries(errorCodes)
|
|
.sort(([aCode], [bCode]) => aCode.localeCompare(bCode))
|
|
.map(([code, definition]) => (
|
|
<TableRow key={code}>
|
|
<TableCell>
|
|
<code className="whitespace-nowrap">{code}</code>
|
|
</TableCell>
|
|
<TableCell>
|
|
<p>{definition.description}</p>
|
|
{!!definition.references && (
|
|
<>
|
|
<p>Learn more:</p>
|
|
<ul>
|
|
{definition.references.map((reference) => (
|
|
<li key={reference.href}>
|
|
<Link href={reference.href}>{reference.description}</Link>
|
|
</li>
|
|
))}
|
|
</ul>
|
|
</>
|
|
)}
|
|
</TableCell>
|
|
</TableRow>
|
|
))}
|
|
</TableBody>
|
|
</Table>
|
|
)
|
|
}
|