aboutsummaryrefslogtreecommitdiff
path: root/themes/default/layouts/_default
diff options
context:
space:
mode:
authortdro <tdro@noreply.example.com>2023-10-07 20:19:06 -0400
committertdro <tdro@noreply.example.com>2023-10-07 20:19:06 -0400
commit829c0162631bec774f00617f4fd2a016ad970c9c (patch)
tree7b58cca29f823a606bb834c0614d6d7c548be784 /themes/default/layouts/_default
parent7c16df7be5050b010eb2386948401230339b5dab (diff)
downloadcanory-829c0162631bec774f00617f4fd2a016ad970c9c.tar.gz
canory-829c0162631bec774f00617f4fd2a016ad970c9c.tar.bz2
canory-829c0162631bec774f00617f4fd2a016ad970c9c.zip
themes/default/layouts/_default/_markup/render-heading: Increase uniqueness
Prevent id conflicts
Diffstat (limited to 'themes/default/layouts/_default')
-rw-r--r--themes/default/layouts/_default/_markup/render-codeblock.html6
-rw-r--r--themes/default/layouts/_default/_markup/render-heading.html4
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 }}">