aboutsummaryrefslogtreecommitdiff
path: root/themes/default/layouts/shortcodes/spoiler.html
diff options
context:
space:
mode:
Diffstat (limited to 'themes/default/layouts/shortcodes/spoiler.html')
-rw-r--r--themes/default/layouts/shortcodes/spoiler.html8
1 files changed, 6 insertions, 2 deletions
diff --git a/themes/default/layouts/shortcodes/spoiler.html b/themes/default/layouts/shortcodes/spoiler.html
index fd3c9d3..ebc3643 100644
--- a/themes/default/layouts/shortcodes/spoiler.html
+++ b/themes/default/layouts/shortcodes/spoiler.html
@@ -1,9 +1,13 @@
{{- $text := default "This is a spoiler." (.Get "text" | default (.Get 0)) -}}
{{- $title := default "Click to show/hide text." (.Get "title" | default (.Get 1)) -}}
+{{- $hash := print (truncate 8 "" (sha256 $text)) .Ordinal -}}
{{- if gt (len .Inner) 1 -}}
{{- $text = .Inner -}}
{{- end -}}
-<input hidden type="checkbox" id="spoiler-text-{{ md5 $text }}" />
-<s title="{{ $title }}"><label for="spoiler-text-{{ md5 $text }}">{{ $text | markdownify }}</label></s>
+<input hidden type="checkbox" id="spoiler-text-{{ $hash }}" />
+
+<s title="{{ $title }}">
+ <label for="spoiler-text-{{ $hash }}">{{ $text | markdownify }}</label>
+</s>