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{ var fontSizeOverrideSelectors = map[string]string{
"h1": "h1", "h2": "h2", "h3": "h3", "h4": "h4", "h5": "h5", "h6": "h6", "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-title": ".bn-hero-title",
"hero-subtitle": ".bn-hero-subtitle", "hero-subtitle": ".bn-hero-subtitle",
"index-card-title": ".bn-post-card-title", "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} 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", FontHeading: "system",
FontBody: "system", FontBody: "system",
FontMono: "system", FontMono: "system",
FontSizeBase: "16", FontSizeBase: "1rem",
LineHeightBase: "1.5", LineHeightBase: "1.5",
FontWeightBase: "normal", FontWeightBase: "normal",
}, },

View File

@ -53,21 +53,29 @@ func ValidateFontSize(v string) error {
return nil return nil
} }
// NormalizeFontSizeBase upgrades legacy bare px numbers ("16") to "16px" and // ParseFontSizeBase normalizes a stored base font size and validates
// validates unit-suffixed values. Returns "" for anything invalid so bad // unit-suffixed values.
// stored data degrades to the CSS fallback instead of breaking the sheet. func ParseFontSizeBase(v string) (string, error) {
func NormalizeFontSizeBase(v string) string {
v = strings.TrimSpace(v) v = strings.TrimSpace(v)
if 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 { if _, err := strconv.ParseFloat(v, 64); err == nil {
v += "px" v = "1rem"
} }
if err := ValidateFontSize(v); err != nil { 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 // SanitizeFontSizeOverrides drops empty values, rejects unknown keys and