feat(gallery): add gallery block with grid/masonry layouts and lightbox

First-class image gallery block. Two layouts ship today - grid (uniform
tiles, configurable columns 1-6, aspect-ratio presets) and masonry
(CSS-columns Pinterest packing). Click-to-zoom lightbox built in Preact,
portalled to <body> so it escapes the section's `isolation: isolate`
stacking context; keyboard navigation (← → Esc), touch swipe, and body
scroll-lock included.

Two source modes: explicit items[] for curated galleries with per-image
captions/credits/links, or album: <folder> for drop-in folder loading
sorted by filename. Remote URLs (Unsplash/Pexels/CDNs) are passed
through unprocessed; local images get the full responsive variants +
inline base64 LQIP placeholder for instant first-paint over the eventual
sharp image.

Captions, titles, and credits are rendered through Hugo's RenderString
at build time (display: inline) - users get full Markdown (bold/italic/
code/links) in any of those fields with zero JS markdown parser. Alt
text falls back to plainified caption → humanised filename so screen
readers always have something useful.

Caption positions: below (default - accessibility-first), overlay
(magazine gradient), hover (clean grid reveal), none (lightbox-only).
Block-scoped CSS in the co-located style.css is picked up by the
existing block-CSS auto-discovery.

Test site: two demos under home.yaml (curated grid + auto-loaded
masonry) with 9 sample Picsum images stored under
test/assets/media/albums/gallery/ at varied aspect ratios.
This commit is contained in:
George Cushen committed 2026-05-17 23:32:49 +01:00
1 parent 4de0ad0af9
commit b67f09b8fd
17 files changed
+725 -13

No files matched your search

+47 -4
View File
@@ -6,12 +6,12 @@ date: 2023-11-01
sections:
- block: hero
content:
title: "**Build Anything** with Hugo Blox"
title: "**Build Anything** with HugoBlox"
text: |
Create stunning websites with our Preact-powered components.
Create stunning websites with Hugo-powered components.
Fast, flexible, and future-proof.
announcement:
text: "🎉 Introducing Preact Components"
text: "🎉 Introducing New Components"
link:
text: "Learn more"
url: "/linked"
@@ -90,10 +90,53 @@ sections:
height: lg
style: light
- block: gallery
content:
title: "Lab tour"
subtitle: "A curated walkthrough — explicit items with captions and credits."
items:
- src: "media/albums/gallery/01-workspace.jpg"
caption: "The **main workspace** where most of our research happens"
credit: "Photo: [Picsum](https://picsum.photos)"
alt: "Open-plan workspace with laptops"
- src: "media/albums/gallery/05-castle.jpg"
title: "Annual retreat"
caption: "*Edinburgh, 2024* — three days of deep work and walks"
credit: "Photo: [Picsum](https://picsum.photos)"
- src: "media/albums/gallery/03-boat.jpg"
caption: "Field trip — coastal data collection on the `Aurora-II`"
credit: "Photo: [Picsum](https://picsum.photos)"
link: "/research/aurora-ii/"
- src: "media/albums/gallery/07-architecture.jpg"
caption: "The new wing opens [in spring](/news/new-wing/)"
credit: "Photo: [Picsum](https://picsum.photos)"
design:
layout: grid
columns: 4
gap: md
aspect_ratio: square
caption_position: below
hover_zoom: true
lightbox: true
- block: gallery
content:
title: "Recent expeditions"
subtitle: "Auto-loaded from `assets/media/albums/gallery/` — captions stay empty when not provided (Slice 1 behaviour)."
album: "media/albums/gallery"
sort: asc
design:
layout: masonry
columns: 3
gap: md
caption_position: overlay
hover_zoom: true
lightbox: true
- block: cta-card
content:
title: "Ready to get started?"
text: "Join 250,000+ users building with Hugo Blox"
text: "Join 150,000+ users building with HugoBlox"
button:
text: "Start Building"
url: "https://hugoblox.com"