From 829c0162631bec774f00617f4fd2a016ad970c9c Mon Sep 17 00:00:00 2001 From: tdro Date: Sat, 7 Oct 2023 20:19:06 -0400 Subject: themes/default/layouts/_default/_markup/render-heading: Increase uniqueness Prevent id conflicts --- themes/default/layouts/_default/_markup/render-codeblock.html | 6 +++--- themes/default/layouts/_default/_markup/render-heading.html | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'themes/default/layouts/_default') 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 -}}
@@ -10,7 +10,7 @@ {{ $type }}
- {{ highlight .Inner $type (print $options ",lineAnchors=" "code-line-" $hash) }} + {{ highlight .Inner $type (print $options ",lineAnchors=" "code-line:" $hash) }}
{{ 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 -}} -- cgit v1.2.3