diff --git a/internal/theme/css.go b/internal/theme/css.go index c57819a..3a19ddd 100644 --- a/internal/theme/css.go +++ b/internal/theme/css.go @@ -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} diff --git a/internal/theme/defaults.go b/internal/theme/defaults.go index 2371718..dcccd0e 100644 --- a/internal/theme/defaults.go +++ b/internal/theme/defaults.go @@ -49,7 +49,7 @@ func DefaultTheme() *Theme { FontHeading: "system", FontBody: "system", FontMono: "system", - FontSizeBase: "16", + FontSizeBase: "1rem", LineHeightBase: "1.5", FontWeightBase: "normal", }, diff --git a/internal/theme/fontsize.go b/internal/theme/fontsize.go index f9e71bb..990d814 100644 --- a/internal/theme/fontsize.go +++ b/internal/theme/fontsize.go @@ -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