This Vento template engine partial works as of Lume v3.0.1. Vento allows you to use javascript code by adding a greater-than sign after the opening curly brackets, like {{> code here}}
.
- An
index.yml
is callinghome.vto
, which is in turn calling thistop-top-hero-ticker-image.vto
partial among others. Theindex.yml
has an array of imageshero.images
which is referenced here. The site is bilingual, so there is a Japanese (default lang)src/index.yml
and an Englishsrc/en/index.yml
. - The
{{> ... const randomIndex
sets up a random index number based on the length of thehero.images
array. - The
randomImage
is then used as the index number to get the info from that image, so it can be referenced directly. - Defaults are set as fallbacks.
- The img tag references the src and alt from the data, of the selected random image.
Every build of Lume, a different image is thus used, adding a little dynamism to the site.
This assumes you're doing a build a day, and that's going to be different on each hosting platform.