diff options
| author | Eltrac <hi@guhub.cn> | 2025-09-23 10:33:07 +0800 |
|---|---|---|
| committer | Eltrac <hi@guhub.cn> | 2025-09-23 10:33:07 +0800 |
| commit | 85ac3f54375f0292b65614af61d2326ab38335bc (patch) | |
| tree | bd28de8bb7da347828b6f3d5ba87fade76c27c52 | |
| parent | 87793e61f2eb8efbe1c536746b11cd9702ec5363 (diff) | |
refactor: size headings based on container font-size
Former-commit-id: d251a4e3f670325569bb0ac5d4943b437c8a89bb
| -rw-r--r-- | layouts/_markup/render-heading.html | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/layouts/_markup/render-heading.html b/layouts/_markup/render-heading.html index 7b076fed..52b2f3ff 100644 --- a/layouts/_markup/render-heading.html +++ b/layouts/_markup/render-heading.html @@ -1,7 +1,12 @@ -{{ $size := index (dict "1" "text-4xl" "2" "text-2xl my-8" "3" "text-xl" "4" "text-lg" "5" "text-base" "6" "text-sm") (printf "%d" .Level) }} -<h{{ .Level }} id="{{ .Anchor }}" - class="{{ if eq .Level 2 }}font-extrabold{{ else }}font-bold{{ end }} - {{ $size }} - {{ with .Attributes.class }} {{ . }}{{ end }}"> +{{ $size := index (dict + "1" "text-[1.5em] font-extrabold" + "2" "text-[1.25em] font-extrabold" + "3" "text-[1.125em] font-bold" + "4" "text-[1em] font-bold" + "5" "text-[0.9em] font-bold" + "6" "text-[0.875em]") (printf "%d" .Level) }} +<h{{ .Level }} + id="{{ .Anchor }}" + class="{{ $size }} {{ with .Attributes.class }} {{ . }}{{ end }}"> {{- .Text -}} </h{{ .Level }}> |
