aboutsummaryrefslogtreecommitdiff
path: root/themes/default/layouts/_default
diff options
context:
space:
mode:
authortdro <tdro@noreply.example.com>2022-11-21 11:23:56 -0500
committertdro <tdro@noreply.example.com>2022-11-21 11:23:56 -0500
commit8113e9c39376d1e9fb1c239a678a7502272e8fda (patch)
treefc1e9263021d886db60a1b22d3cfee3b7bfa410d /themes/default/layouts/_default
parent4a82e6046ab0e8cf65a089a7b1e85c6ef918666c (diff)
downloadcanory-8113e9c39376d1e9fb1c239a678a7502272e8fda.tar.gz
canory-8113e9c39376d1e9fb1c239a678a7502272e8fda.tar.bz2
canory-8113e9c39376d1e9fb1c239a678a7502272e8fda.zip
themes/default/layouts: Use hashing algorithm consistently
Avoid using shuffle in short codes by appending .Ordinal value
Diffstat (limited to 'themes/default/layouts/_default')
-rw-r--r--themes/default/layouts/_default/_markup/render-codeblock.html5
-rw-r--r--themes/default/layouts/_default/index.json2
2 files changed, 4 insertions, 3 deletions
diff --git a/themes/default/layouts/_default/_markup/render-codeblock.html b/themes/default/layouts/_default/_markup/render-codeblock.html
index 22d47e4..d629a85 100644
--- a/themes/default/layouts/_default/_markup/render-codeblock.html
+++ b/themes/default/layouts/_default/_markup/render-codeblock.html
@@ -1,7 +1,8 @@
{{- $caption := .Attributes.caption -}}
{{- $type := .Type | default "text" -}}
{{- $options := .Attributes.options | default "default=1" -}}
-{{- $id := print "code-block-" (truncate 7 "" (md5 .Inner)) -}}
+{{- $hash := print (truncate 8 "" (sha256 .Inner)) .Ordinal -}}
+{{- $id := print "code-block-" $hash -}}
<code-block id="{{ $id }}" {{ if in (lower $options) "linenos" }}data-lines{{ end }}>
<header>
@@ -13,7 +14,7 @@
<span>Copy</span>
</button>
</header>
- {{ highlight .Inner $type (print $options ",lineAnchors=" "code-line-" (truncate 7 "" (md5 .Inner))) }}
+ {{ highlight .Inner $type (print $options ",lineAnchors=" "code-line-" $hash) }}
</code-block>
{{ with $caption }}
diff --git a/themes/default/layouts/_default/index.json b/themes/default/layouts/_default/index.json
index 78c0fde..86641fa 100644
--- a/themes/default/layouts/_default/index.json
+++ b/themes/default/layouts/_default/index.json
@@ -13,7 +13,7 @@
{{- range $index, $data := $filteredPages -}}
{{- if and $index (gt $index 0) -}},{{- end }}
{
- "id": "{{ md5 $data.Permalink }}",
+ "id": "{{ sha256 $data.Permalink }}",
"url": "{{ $data.Permalink }}",
"title": "{{ $data.Summary | htmlUnescape }}",
"summary": "{{ $data.Summary | htmlUnescape }}",