diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2021-04-04 20:05:42 +0300 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2021-04-04 20:16:53 +0300 |
commit | 0ecdc45fc2a12f9d60b8478177873bac3bc22259 (patch) | |
tree | 6801cb08343c5ad6f6142bb84450070a9a1bab88 | |
parent | b2ff8980999293495dedfe66e39012487a06779e (diff) |
Make the IDs unique
See #37
-rw-r--r-- | config.toml | 2 | ||||
-rw-r--r-- | layouts/_default/_markup/render-heading.html | 15 |
2 files changed, 16 insertions, 1 deletions
diff --git a/config.toml b/config.toml index 41d3404..ee56fd7 100644 --- a/config.toml +++ b/config.toml @@ -3,7 +3,7 @@ baseURL = "https://example.com/" [module] [module.hugoVersion] -min = "0.56.0" +min = "0.71.0" [[module.imports]] path="github.com/jquery/jquery-dist" [[module.imports.mounts]] diff --git a/layouts/_default/_markup/render-heading.html b/layouts/_default/_markup/render-heading.html new file mode 100644 index 0000000..0e4f6ab --- /dev/null +++ b/layouts/_default/_markup/render-heading.html @@ -0,0 +1,15 @@ +{{ $anchor := .Anchor }} +{{ $s := site.Home.Scratch }} +{{ $anchors := $s.Get "anchors" }} +{{ if $anchors }} + {{ if index $anchors .Anchor }} + {{ range seq 10 }} + {{ if index $anchors $anchor }} + {{ $anchor = printf "%s-%d" $.Anchor . }} + {{ end }} + {{ end }} + {{ end }} +{{ end }} +{{ $s.SetInMap "anchors" $anchor true }} +{{ $h := printf "<h%d id=%q>%s</h%d>" .Level $anchor .Text .Level }} +{{ $h | safeHTML }}
\ No newline at end of file |