chore(theme): re-vendor cms theme copies after nav-link and rem-first fixes

Picks up the post-title/post-lede selectors, the narrowed .bn-nav-link
selector, the rem-first default base size and ParseFontSizeBase.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Alex Dunmow 2026-08-03 23:26:53 +08:00
parent dd82b88e26
commit 6fb2519cfd
3 changed files with 20 additions and 10 deletions

View File

@ -148,10 +148,12 @@ func writeTypographyVars(css *strings.Builder, typography *ThemeTypography) {
var fontSizeOverrideSelectors = map[string]string{
"h1": "h1", "h2": "h2", "h3": "h3", "h4": "h4", "h5": "h5", "h6": "h6",
"nav-link": ".bn-navbar a",
"nav-link": ".bn-nav-link",
"hero-title": ".bn-hero-title",
"hero-subtitle": ".bn-hero-subtitle",
"index-card-title": ".bn-post-card-title",
"post-title": ".bn-post-title",
"post-lede": ".bn-post-lede",
}
var headingOverrideKeys = map[string]bool{"h1": true, "h2": true, "h3": true, "h4": true, "h5": true, "h6": true}

View File

@ -49,7 +49,7 @@ func DefaultTheme() *Theme {
FontHeading: "system",
FontBody: "system",
FontMono: "system",
FontSizeBase: "16",
FontSizeBase: "1rem",
LineHeightBase: "1.5",
FontWeightBase: "normal",
},

View File

@ -53,21 +53,29 @@ func ValidateFontSize(v string) error {
return nil
}
// NormalizeFontSizeBase upgrades legacy bare px numbers ("16") to "16px" and
// validates unit-suffixed values. Returns "" for anything invalid so bad
// stored data degrades to the CSS fallback instead of breaking the sheet.
func NormalizeFontSizeBase(v string) string {
// ParseFontSizeBase normalizes a stored base font size and validates
// unit-suffixed values.
func ParseFontSizeBase(v string) (string, error) {
v = strings.TrimSpace(v)
if v == "" {
return ""
return "", nil
}
// Legacy bare numbers were never consumed by any stylesheet, so they are
// normalized to the 1rem default rather than resurrected as a real size.
if _, err := strconv.ParseFloat(v, 64); err == nil {
v += "px"
v = "1rem"
}
if err := ValidateFontSize(v); err != nil {
return ""
return "", err
}
return v
return v, nil
}
// NormalizeFontSizeBase returns "" for anything invalid so bad stored data
// degrades to the CSS fallback instead of breaking the sheet.
func NormalizeFontSizeBase(v string) string {
out, _ := ParseFontSizeBase(v)
return out
}
// SanitizeFontSizeOverrides drops empty values, rejects unknown keys and