diff options
author | tdro <tdro@noreply.example.com> | 2023-10-07 20:19:06 -0400 |
---|---|---|
committer | tdro <tdro@noreply.example.com> | 2023-10-07 20:19:06 -0400 |
commit | 829c0162631bec774f00617f4fd2a016ad970c9c (patch) | |
tree | 7b58cca29f823a606bb834c0614d6d7c548be784 | |
parent | 7c16df7be5050b010eb2386948401230339b5dab (diff) | |
download | canory-829c0162631bec774f00617f4fd2a016ad970c9c.tar.gz canory-829c0162631bec774f00617f4fd2a016ad970c9c.tar.bz2 canory-829c0162631bec774f00617f4fd2a016ad970c9c.zip |
themes/default/layouts/_default/_markup/render-heading: Increase uniqueness
Prevent id conflicts
-rw-r--r-- | themes/default/layouts/_default/_markup/render-codeblock.html | 6 | ||||
-rw-r--r-- | themes/default/layouts/_default/_markup/render-heading.html | 4 |
2 files changed, 5 insertions, 5 deletions
diff --git a/themes/default/layouts/_default/_markup/render-codeblock.html b/themes/default/layouts/_default/_markup/render-codeblock.html index 3529dc4..1321d8e 100644 --- a/themes/default/layouts/_default/_markup/render-codeblock.html +++ b/themes/default/layouts/_default/_markup/render-codeblock.html @@ -1,8 +1,8 @@ {{- $caption := .Attributes.caption -}} {{- $type := .Type | default "text" -}} {{- $options := .Attributes.options | default "default=1" -}} -{{- $hash := print (truncate 8 "" (sha256 .Inner)) .Ordinal -}} -{{- $id := print "code-block-" $hash -}} +{{- $hash := print (truncate 3 "" (sha256 .Inner)) (truncate 3 "" (sha256 .Page.RelPermalink)) .Ordinal -}} +{{- $id := print "code-block:" $hash | safeURL -}} <code-block id="{{ $id }}" {{ if in (lower $options) "linenos" }}data-lines=""{{ end }}> <header> @@ -10,7 +10,7 @@ <a href="#{{ $id }}">{{ $type }}</a> </language-label> </header> - {{ highlight .Inner $type (print $options ",lineAnchors=" "code-line-" $hash) }} + {{ highlight .Inner $type (print $options ",lineAnchors=" "code-line:" $hash) }} </code-block> {{ with $caption }} diff --git a/themes/default/layouts/_default/_markup/render-heading.html b/themes/default/layouts/_default/_markup/render-heading.html index fdbe807..86b8e35 100644 --- a/themes/default/layouts/_default/_markup/render-heading.html +++ b/themes/default/layouts/_default/_markup/render-heading.html @@ -1,6 +1,6 @@ {{- $text := .Text -}} -{{- $hash := print (truncate 8 "" (sha256 .Page.Permalink)) -}} -{{- $id := print $hash "-" .Anchor -}} +{{- $hash := print (truncate 2 "" (sha256 .Page.RelPermalink)) (truncate 2 "" (sha256 $text)) -}} +{{- $id := print "heading:" $hash ":" .Anchor -}} <h{{ .Level }} id="{{ $id | safeURL }}"> <a title="{{ $text | safeHTML }}" href="#{{ $id | safeURL }}"> |