|
| 1 | +import Link from "next/link" |
| 2 | +import { |
| 3 | + buildGlossaryTopicBlocks, |
| 4 | + formatGlossarySlugForDisplay, |
| 5 | + parseGlossaryEntries, |
| 6 | + readMetricGlossaryMarkdown, |
| 7 | +} from "@/lib/metric-glossary" |
| 8 | + |
| 9 | +const BOLD_LEAD_PARAGRAPH = /^\*\*([^*]+)\*\*:\s*([\s\S]*)$/ |
| 10 | + |
| 11 | +function GlossaryBody({ text }: { text: string }) { |
| 12 | + const paragraphs = text.split(/\n\n+/).filter(Boolean) |
| 13 | + return ( |
| 14 | + <div className="space-y-3 text-sm text-muted-foreground"> |
| 15 | + {paragraphs.map((p, i) => { |
| 16 | + const boldLead = BOLD_LEAD_PARAGRAPH.exec(p) |
| 17 | + if (boldLead) { |
| 18 | + return ( |
| 19 | + <p key={i}> |
| 20 | + <span className="font-medium text-foreground">{boldLead[1]}:</span> {boldLead[2]} |
| 21 | + </p> |
| 22 | + ) |
| 23 | + } |
| 24 | + return <p key={i}>{p}</p> |
| 25 | + })} |
| 26 | + </div> |
| 27 | + ) |
| 28 | +} |
| 29 | + |
| 30 | +export default function GlossaryPage() { |
| 31 | + const md = readMetricGlossaryMarkdown() |
| 32 | + const entries = parseGlossaryEntries(md) |
| 33 | + const topicBlocks = buildGlossaryTopicBlocks(entries) |
| 34 | + const alphaSlugs = Object.keys(entries).sort((a, b) => a.localeCompare(b)) |
| 35 | + |
| 36 | + return ( |
| 37 | + <div className="min-h-screen bg-background"> |
| 38 | + <div className="container mx-auto max-w-4xl p-6 space-y-10"> |
| 39 | + <header className="space-y-2 border-b border-border pb-6"> |
| 40 | + <h1 className="text-3xl font-bold tracking-tight">Metric glossary</h1> |
| 41 | + <p className="text-muted-foreground"> |
| 42 | + In-context definitions for dashboard KPIs, with PDP field notes and high-level IPEDS / state |
| 43 | + cross-walks. Source:{" "} |
| 44 | + <code className="text-xs bg-muted px-1 py-0.5 rounded">content/metric-glossary.md</code> |
| 45 | + </p> |
| 46 | + <p className="text-sm text-muted-foreground"> |
| 47 | + <Link href="/" className="text-primary underline-offset-4 hover:underline"> |
| 48 | + Back to dashboard |
| 49 | + </Link> |
| 50 | + {" · "} |
| 51 | + <Link href="/methodology" className="text-primary underline-offset-4 hover:underline"> |
| 52 | + Methodology |
| 53 | + </Link> |
| 54 | + </p> |
| 55 | + </header> |
| 56 | + |
| 57 | + <nav aria-label="On this page" className="rounded-lg border border-border bg-muted/30 p-4 space-y-3"> |
| 58 | + <h2 className="text-sm font-semibold text-foreground">By topic</h2> |
| 59 | + <ul className="flex flex-wrap gap-x-4 gap-y-1 text-sm"> |
| 60 | + {topicBlocks.map((t) => ( |
| 61 | + <li key={t.id}> |
| 62 | + <a href={`#topic-${t.id}`} className="text-primary underline-offset-4 hover:underline"> |
| 63 | + {t.label} |
| 64 | + </a> |
| 65 | + </li> |
| 66 | + ))} |
| 67 | + </ul> |
| 68 | + <h2 className="text-sm font-semibold text-foreground pt-2">A–Z</h2> |
| 69 | + <ul className="flex flex-wrap gap-x-3 gap-y-1 text-xs font-mono text-muted-foreground"> |
| 70 | + {alphaSlugs.map((slug) => ( |
| 71 | + <li key={slug}> |
| 72 | + <a href={`#${slug}`} className="hover:text-foreground underline-offset-2 hover:underline"> |
| 73 | + {formatGlossarySlugForDisplay(slug)} |
| 74 | + </a> |
| 75 | + </li> |
| 76 | + ))} |
| 77 | + </ul> |
| 78 | + </nav> |
| 79 | + |
| 80 | + {topicBlocks.map((topic) => ( |
| 81 | + <section key={topic.id} id={`topic-${topic.id}`} className="space-y-6 scroll-mt-20"> |
| 82 | + <h2 className="text-xl font-semibold tracking-tight border-b border-border pb-2">{topic.label}</h2> |
| 83 | + {topic.slugs.map((slug) => { |
| 84 | + const body = entries[slug]! |
| 85 | + const title = formatGlossarySlugForDisplay(slug) |
| 86 | + return ( |
| 87 | + <article key={slug} id={slug} className="scroll-mt-20 space-y-2 rounded-lg border border-border p-5"> |
| 88 | + <h3 className="text-lg font-medium capitalize">{title}</h3> |
| 89 | + <GlossaryBody text={body} /> |
| 90 | + </article> |
| 91 | + ) |
| 92 | + })} |
| 93 | + </section> |
| 94 | + ))} |
| 95 | + |
| 96 | + <footer className="text-xs text-muted-foreground border-t border-border pt-6"> |
| 97 | + <p> |
| 98 | + Epic tracking:{" "} |
| 99 | + <a |
| 100 | + href="https://github.com/devcolor/codebenders-datathon/issues/124" |
| 101 | + className="text-primary underline-offset-4 hover:underline" |
| 102 | + > |
| 103 | + #124 AASCU convening follow-ups |
| 104 | + </a> |
| 105 | + {" · "}Issue{" "} |
| 106 | + <a |
| 107 | + href="https://github.com/devcolor/codebenders-datathon/issues/105" |
| 108 | + className="text-primary underline-offset-4 hover:underline" |
| 109 | + > |
| 110 | + #105 |
| 111 | + </a> |
| 112 | + </p> |
| 113 | + </footer> |
| 114 | + </div> |
| 115 | + </div> |
| 116 | + ) |
| 117 | +} |
0 commit comments