Usage
{{< heroslider [from = "heroslider-sponsors"] [height = "30svh"] [srcOn = "top"] >}}A slider of image + text slides from a data file, sized by CSS geometry. In a hero it sits at the top or bottom of the band and the heading content lays out around it.
Description
Renders one slide per item of a data-file list. Each slide is any combination of image (src) and text (header + text), optionally linked. Images go through tool/media and tk/get-asset with process, so only the processed copy is published. Text goes through tool/caption, restyled by .heroslider .caption. Settings layer: built-in defaults, then the data file, then the page’s heroslider front matter, then hw props.
Parameters
indicates required parameter
from =
"string"front matter `heroslider`, else data/heroslider
Data file holding the settings (and the slides unless it sets
includedata). Extension optional; yaml, json or tomlheader =
"string"Slides
The carousel’s aria-label. Not a heading: the hero owns the page’s h1
srcOn =
"string"left
left | right (side by side), top (image over text), bottom (text over image). Also per slide. Via hw,
left cannot override a data file’s valuesrcWidth =
"number"0.4
0.0-1.0: the image’s share of a left/right slide. Also per slide
process =
"string"fit 600x400 webp q80
Hugo process string for raster slides. Also per slide
height =
"string"25svh
CSS length; overrides geometry.height
count =
"number"all
Show at most this many slides. Via hw, only values above 1 apply
skip =
"number"0
Skip this many slides from the start
class =
"string"
Extra classes on the
.heroslider sectionid =
"string"heroslider-<hash of from>
Anchor id of the section
Examples
Hero slider from front matter
{{- $slider := partial "tool/heroslider" (dict "page" .Page) -}}
{{- partial "tool/cover" (dict "page" .Page "src" .Params.image
"header" .Title "class" "has-heroslider" "afterHTML" $slider) -}}A hero partial, with
heroslider: heroslider-sponsors in the page front matter. The slider sits at the bottom of the band, 80vw x 25svh, 1em from the edgeFront matter overrides
heroslider:
from: heroslider-sponsors
srcOn: top
geometry: {top: 2em, height: 30svh}top replaces the data file’s bottom: the slider moves to the top of the bandData file (data/heroslider-sponsors.yaml)
includedata: sponsors.yaml
slides: sponsors
map: {header: name, text: summary, src: logo, link: link}
interval: 6
geometry: {width: 80vw, height: 25svh, bottom: 1em, align: center}Omit
includedata and put a slides: list of src/header/text/link items in the file itselfIn normal flow on any page
{{<hw t="heroslider" from="heroslider-sponsors" height="20svh" />}}Same markup outside a hero; geometry.top/bottom become margins
Additional Information