Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/bep/docuapi.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2021-04-04 20:05:42 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2021-04-04 20:16:53 +0300
commit0ecdc45fc2a12f9d60b8478177873bac3bc22259 (patch)
tree6801cb08343c5ad6f6142bb84450070a9a1bab88
parentb2ff8980999293495dedfe66e39012487a06779e (diff)
Make the IDs unique
See #37
-rw-r--r--config.toml2
-rw-r--r--layouts/_default/_markup/render-heading.html15
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