{{- /* resource-tiles — display a page's file resources as a responsive grid of cards ("tiles"), each with a thumbnail, a title, the file size and a download link. Handy for a downloads page that offers a handful of PDFs, spreadsheets, archives, … Params: match glob selecting which page resources to show (default "*.pdf") cols number of columns on large screens (default 3) sort resource field to order by: "title", "name" or "weight" (default: the order they appear in front matter) class extra CSS classes for the wrapping row Thumbnails are resolved per resource, in order of preference: 1. a `thumbnail` param on the resource, pointing at an image in the same page bundle 2. an image resource whose name matches the file, e.g. `report.png` or `report.pdf.png` next to `report.pdf` 3. a generic file icon showing the upper-cased extension Per-resource metadata is read from the page's front matter: resources: - src: report.pdf title: Annual report params: description: Everything that happened last year. thumbnail: report-cover.png */ -}} {{- $page := .Page -}} {{- $match := or (.Get "match") "*.pdf" -}} {{- $cols := or (.Get "cols") 3 -}} {{- $class := .Get "class" -}} {{- $imgExts := slice "png" "jpg" "jpeg" "webp" "gif" "avif" -}} {{- $resources := $page.Resources.Match $match -}} {{- with .Get "sort" -}} {{- $resources = sort $resources . -}} {{- end -}} {{- with $resources -}}
{{ $page.RenderString . }}
{{- end }}