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.ymlis callinghome.vto, which is in turn calling thistop-top-hero-ticker-image.vtopartial among others. Theindex.ymlhas an array of imageshero.imageswhich is referenced here. The site is bilingual, so there is a Japanese (default lang)src/index.ymland an Englishsrc/en/index.yml. - The
{{> ... const randomIndexsets up a random index number based on the length of thehero.imagesarray. - The
randomImageis 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.