hello, i am quite new to posting, so i hope that i get this right,
i have a data file, data/poemes_aleatoires/poemes.toml, that contains a list of “poemes” like this :
[[poeme]]
texte = "1"
[[poeme]]
texte = "2"
[[poeme]]
texte = "3"
and so on…
i would like a page, content/poemes/test.md, to randomly show one of the texte from poemes.toml upon page load.
so i made a template for test.md, which is layouts/poemes/test.html.html that contains those lines inside body:
{{ range .Site.Data.poemes_aleatoires.poemes.poeme | shuffle | first 1 }}
<label>
{{.texte}}<br>
</label>
{{ end }}
the problem is that when building the site with hugo server
, i am building it locally, the texte shown is randomly picked, but i cannot manage to have an other random pick upon page reload…
i tried stuff like window.onload
and have experimented a bit of javascript, but i cannot make it work… i probably misunderstand how those works…
hope i gave enough information and that someone can help me out
in case, the whole code is here https://github.com/demaria-matteo/poemesperdus
thanks