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