Merge pull request 'Add missing JSON.parse, proper random id generation and more images' (#34) from improve_thanks into main
Reviewed-on: #34pull/37/head
commit
fc6b784a15
|
@ -13,6 +13,8 @@ image:
|
|||
- /intern/thanks/awesome-dog.jpg
|
||||
- /intern/thanks/could-you-get-any-cooler.jpg
|
||||
- /intern/thanks/t_hanks.jpg
|
||||
- /intern/thanks/thank-you.jpg
|
||||
- /intern/thanks/thanks-for-your-help.jpg
|
||||
---
|
||||
|
||||
{{< random_image >}}
|
||||
|
|
|
@ -3,14 +3,14 @@
|
|||
{{- errorf "missing value for 'image.choices': %s" .Position }}
|
||||
{{- end }}
|
||||
{{- $alt := default "random image" ($.Page.Param "image.alt") }}
|
||||
{{- $id := sha256 now.UnixNano }}
|
||||
{{- $id := sha256 (index (seq 999 | shuffle) 0) }}
|
||||
<p id="{{ $id }}">
|
||||
<img class="centered pad-vertical" >
|
||||
</p>
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
const container = document.getElementById("{{ $id }}");
|
||||
const choices = {{ $choices }};
|
||||
const choices = JSON.parse(`{{ $choices }}`);
|
||||
if (!container || !choices) { return; }
|
||||
const img = document.createElement("img");
|
||||
img.alt = "{{ $alt }}";
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 26 KiB |
Binary file not shown.
After Width: | Height: | Size: 79 KiB |
Loading…
Reference in New Issue