open-navigator / web_app /src /lib /themeLabel.ts
jcbowyer's picture
Clean HuggingFace deployment without binary files
a8fb296
Raw History Blame Contribute Delete
547 Bytes
/**
* Readable label for a coarse `primary_theme` code (#499):
* "economic_development" / "ECONOMIC_DEVELOPMENT" → "Economic development".
* Returns null for empty or the "__unthemed__" sentinel so callers can hide it.
*/
export function themeLabel(code: string | null | undefined): string | null {
const raw = (code ?? '').trim()
if (!raw || raw === '__unthemed__') return null
const words = raw.replace(/[_-]+/g, ' ').replace(/\s+/g, ' ').trim().toLowerCase()
return words ? words.charAt(0).toUpperCase() + words.slice(1) : null
}