diff options
Diffstat (limited to 'themes/default/layouts/shortcodes/spoiler.html')
-rw-r--r-- | themes/default/layouts/shortcodes/spoiler.html | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/themes/default/layouts/shortcodes/spoiler.html b/themes/default/layouts/shortcodes/spoiler.html index 9267876..9c5e59a 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 4 "" (sha256 .Page.RelPermalink)) (truncate 4 "" (sha256 $text)) .Ordinal -}} -{{ if gt (len .Inner) 1 }} - {{ $text = .Inner }} -{{ end }} +{{- 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> |