Feat: add page param decreaseH1 to decrease the H1 heading level in content

This commit is contained in:
Cell
2025-08-17 15:13:14 +08:00
parent 77fcd7fa93
commit 014e1fa67c
3 changed files with 7 additions and 4 deletions
+2
View File
@@ -1070,6 +1070,8 @@ mainSections = []
ordered = false
startLevel = 2
endLevel = 6
# FixIt 0.4.0 | NEW whether to decrease the H1 heading level in content
decreaseH1 = false
# FixIt 0.2.13 | NEW Display a message at the beginning of an article to warn the reader that its content might be expired
[params.page.expirationReminder]
enable = false
+4 -3
View File
@@ -17,7 +17,7 @@
{{- $h5Format := $headingConfig.number.format.h5 | default "{h2}.{h3}.{h4}.{h5} {title}" -}}
{{- $h6Format := $headingConfig.number.format.h6 | default "{h2}.{h3}.{h4}.{h5}.{h6} {title}" -}}
{{- $level := .Level -}}
{{- $maxMarkupLevel := 2 -}}
{{- $maxMarkupLevel := cond $toc.decreaseH1 2 1 -}}
{{- /* Disable ordered headings on home page */ -}}
{{- if eq hugo.Context.MarkupScope "home" -}}
@@ -45,8 +45,9 @@
{{- $attrs = partial "function/trim.html" $attrs -}}
{{- /* Force decrease the markup level to avoid multiple h1 */ -}}
{{- $markupLevel := cond (gt $maxMarkupLevel $level) $maxMarkupLevel $level -}}
<h{{ $markupLevel }} {{ $attrs | safeHTMLAttr }}>
{{- $decreased := gt $maxMarkupLevel $level -}}
{{- $markupLevel := cond $decreased $maxMarkupLevel $level -}}
<h{{ $markupLevel }} {{ $attrs | safeHTMLAttr }}{{ with $decreased }} data-decreased{{ end }}>
{{- $title := .Text -}}
{{- if $ordered -}}
{{- /* Add 1 to the current level */ -}}
+1 -1
View File
@@ -1,4 +1,4 @@
{{- hugo.Store.Set "version" "v0.4.0-alpha-20250814132913-e04bb611" -}}
{{- hugo.Store.Set "version" "v0.4.0-alpha-20250817071316-77fcd7fa" -}}
{{- .Store.Set "this" dict -}}
{{- partial "init/detection-env.html" . -}}