| 1 | import type { ReactNode } from "react"; |
| 2 | |
| 3 | import { REPOSITORY_URL } |
| 4 | |
| 5 | /** A link to a file in the repository, named by its path and, optionally, the symbol to look for in it. Symbols rather than line numbers, so a link survives edits. */ |
| 6 | export function Source({ |
| 7 | path, |
| 8 | symbol, |
| 9 | children, |
| 10 | }: { |
| 11 | path: string |
| 12 | symbol?: string |
| 13 | children?: ReactNode |
| 14 | }) { |
| 15 | const kind = |
| 16 | return ( |
| 17 | <a |
| 18 | href={`${REPOSITORY_URL |
| 19 | target="_blank" |
| 20 | rel="noreferrer" |
| 21 | className="font-mono text-[0.85em]" |
| 22 | > |
| 23 | {children ?? (symbol |
| 24 | </a> |
| 25 | ); |
| 26 | } |
| 27 | |
| 28 | /** A design decision in `docs/`, by its number and file name. */ |
| 29 | export function Adr({ |
| 30 | file, |
| 31 | children, |
| 32 | }: { |
| 33 | file: string |
| 34 | children?: ReactNode |
| 35 | }) { |
| 36 | return ( |
| 37 | <Source path={ |
| 38 | {children ?? `ADR |
| 39 | </Source> |
| 40 | ); |
| 41 | } |