feat: add site-wide glossary with hover tooltips
CI / TypeScript — type-check (push) Successful in 8s
CI / Publish — build & push image (push) Successful in 8s
CI / Deploy — pull & restart on host (push) Successful in 2s

Every abbreviation and technical term used in the site's copy (RBAC,
NAPALM, config drift, ...) now links to a new /glossary page and shows
a short definition on hover, wherever it appears in body text. Product
and vendor brand names are deliberately excluded — the glossary stays
a dictionary of vocabulary, not a company directory.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Christian Manivong
2026-07-02 18:37:35 +02:00
co-authored by Claude Sonnet 5
parent 2a8a87bdd1
commit 38c7fb1db9
14 changed files with 758 additions and 31 deletions
+33
View File
@@ -0,0 +1,33 @@
import { Fragment } from 'react'
import GlossaryMark from '../components/GlossaryMark'
import { GLOSSARY } from '../glossary/terms'
function escapeRegExp(value: string): string {
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
}
const MATCH_TO_ID = new Map<string, string>()
for (const entry of GLOSSARY) {
for (const surface of entry.match) {
MATCH_TO_ID.set(surface, entry.id)
}
}
const ALL_SURFACES = [...MATCH_TO_ID.keys()].sort((a, b) => b.length - a.length)
const GLOSSARY_REGEX = new RegExp(`\\b(${ALL_SURFACES.map(escapeRegExp).join('|')})\\b`, 'g')
/** Wraps every occurrence of a known glossary term in `text` with a hoverable, linked <GlossaryMark>. */
export function linkify(text: string): React.ReactNode {
const parts = text.split(GLOSSARY_REGEX)
if (parts.length === 1) return text
return parts.map((part, i) => {
const id = MATCH_TO_ID.get(part)
if (id === undefined) return <Fragment key={i}>{part}</Fragment>
return (
<GlossaryMark key={i} id={id}>
{part}
</GlossaryMark>
)
})
}