Files
George Cushen 80913c028a feat(hero): Phase 3 — media slot and split-layout variants
- New `content.media` field accepts image (Hugo-pipeline-processed for
  responsive srcset) or video (passes through as <video>). Optional
  `dark_src` provides a dark-mode image variant.
- New `design.layout` enum: centered (default) | split-left |
  split-right | stacked. Split layouts auto-set alignment to 'left'
  unless explicitly overridden.
- Bump trust-strip star size from w-4 to w-5 for visual presence.
- Two new shared partials in layouts/_partials/functions/:
  - resolve_image_resource: path → {resource | fallback_url}
  - process_image_for_props: path → {src, srcset, width, height}
  These factor out the resource-resolution + responsive-processing
  pipeline so media-bearing blocks don't have to inline it.
- Capabilities registry: media-image, media-video, split-layouts.
- Landing page _index.md: keeps the centered hero (no behavioural
  change) but documents the opt-in pattern for split layouts inline.
2026-05-02 17:52:57 +01:00

55 lines
2.0 KiB
HTML

{{/*
resolve_image_resource — Resolves an image path string to either a Hugo image
resource or a fallback URL. Handles remote URLs, page resources, and assets/media
lookups using the same rules as the inline per-item image resolver.
Inputs:
.path: image path (required) — relative ("dashboard.png", "media/foo.jpg")
or absolute URL ("https://…").
.Page: current page (optional, recommended for page-resource lookup).
Returns dict with one of:
.resource: Hugo image resource (use with .Process, srcset, etc.)
.fallback_url: plain URL string (use as <img src>)
Or an empty dict if path is missing.
*/}}
{{ $result := dict }}
{{ $path := strings.TrimSpace (printf "%v" (.path | default "")) }}
{{ if $path }}
{{ $is_remote := or (strings.HasPrefix $path "http://") (strings.HasPrefix $path "https://") }}
{{ if $is_remote }}
{{ $remote := try (resources.GetRemote $path) }}
{{ if and $remote (not $remote.Err) }}
{{ $result = dict "resource" $remote.Value }}
{{ else }}
{{ $result = dict "fallback_url" $path }}
{{ end }}
{{ else }}
{{ $normalized := $path }}
{{ $normalized = strings.TrimPrefix "/" $normalized }}
{{ $normalized = strings.TrimPrefix "./" $normalized }}
{{ $normalized = strings.TrimPrefix "assets/" $normalized }}
{{ $normalized = strings.TrimPrefix "media/" $normalized }}
{{ $normalized = path.Clean $normalized }}
{{ if and $normalized (ne $normalized ".") }}
{{ $resource := false }}
{{ with .Page }}
{{ $resource = (.Resources.ByType "image").GetMatch $normalized }}
{{ end }}
{{ if not $resource }}
{{ $resource = resources.Get (path.Join "media" $normalized) }}
{{ end }}
{{ if $resource }}
{{ $result = dict "resource" $resource }}
{{ else }}
{{ $result = dict "fallback_url" (printf "/media/%s" $normalized) }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ return $result }}