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 calling home.vto
, which is in turn calling this top-top-hero-ticker-image.vto
partial among others. The index.yml
has an array of images hero.images
which is referenced here. The site is bilingual, so there is a Japanese (default lang) src/index.yml
and an English src/en/index.yml
.
- The
{{> ... const randomIndex
sets up a random index number based on the length of the hero.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.