mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-09-03 04:02:40 +00:00
✨ Feat: add onlyMainSection option for page auto heading numbering
This commit is contained in:
@@ -698,6 +698,8 @@ enableEmoji = true
|
||||
[params.page.heading.number]
|
||||
# whether to enable auto heading numbering
|
||||
enable = false
|
||||
# FixIt 0.3.3 | NEW only enable in main section pages (default is posts)
|
||||
onlyMainSection = true
|
||||
[params.page.heading.number.format]
|
||||
h1 = "{title}"
|
||||
h2 = "{h2} {title}"
|
||||
|
||||
@@ -15,7 +15,10 @@
|
||||
<h{{ .Level }} id="{{ .Anchor | safeURL }}" class="heading-element">
|
||||
<a href="#{{ .Anchor | safeURL }}" class="heading-mark"></a>
|
||||
|
||||
{{- if $params.heading.number.enable -}}
|
||||
|
||||
{{- /* Only enable in main section pages */ -}}
|
||||
{{- $onlyMainSection := cond $params.heading.number.onlyMainSection (eq .Page.Type "posts") true -}}
|
||||
{{- if $params.heading.number.enable | and $onlyMainSection -}}
|
||||
{{- /* Add 1 to the current level */ -}}
|
||||
{{- $headingMap := .Page.Scratch.Get "heading-counter" -}}
|
||||
{{- $count := (string .Level) | index $headingMap | int | add 1 -}}
|
||||
|
||||
Reference in New Issue
Block a user