Files
blowfish/layouts/partials/hero/thumbAndBackground.html
T
Nuno CoraçãoandClaude Fable 5 09f0573749 ✨ v3 theme: glass UI, landing layout, a11y, perf, print styles
Floating glass header with ⌘K search, landing homepage layout with
hero image and GitHub-stars CTA, background canvas with dissolving
heroes, burufugu colour scheme, movie-quote 404, taxonomy pills,
keyboard/ARIA accessibility across menus, search and tabs, idle-
loaded third-party scripts, and dedicated print styles.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-17 20:19:02 +01:00

150 lines
5.5 KiB
HTML

{{ $disableImageOptimization := site.Store.Get "disableImageOptimization" }}
{{/* === Background === */}}
{{ $useDefault := false }}
{{ $images := .Resources.ByType "image" }}
{{ $background := $images.GetMatch "*background*" }}
{{ $backgroundURL := "" }}
{{/* When the site-wide background canvas is active it already renders the
default background image, so only fall back to it here when disabled. */}}
{{ if and (not (or $background $backgroundURL)) (not (site.Params.backgroundCanvas | default false)) }}
{{ $default := site.Store.Get "defaultBackgroundImage" }}
{{ if $default.url }}
{{ $backgroundURL = $default.url }}
{{ $useDefault = true }}
{{ else if $default.obj }}
{{ $background = $default.obj }}
{{ $useDefault = true }}
{{ end }}
{{ end }}
{{ if not (or $background $backgroundURL) }}
{{ range slice "*cover*" "*thumbnail*" "*feature*" }}
{{ if not $background }}{{ $background = $images.GetMatch . }}{{ end }}
{{ end }}
{{ end }}
{{/* generate image URL if not hotlink */}}
{{ if not $backgroundURL }}
{{ with $background }}
{{ $backgroundURL = .RelPermalink }}
{{ if not (or $disableImageOptimization (eq .MediaType.SubType "svg")) }}
{{ $size := site.Store.Get "backgroundImageWidth" }}
{{ $backgroundURL = (partial "functions/resize.html" (dict "resource" . "spec" $size)).RelPermalink }}
{{ end }}
{{ end }}
{{ end }}
{{/* === Featured === */}}
{{ $featured := "" }}
{{ $featuredURL := "" }}
{{ with partial "functions/feature-image.html" . }}
{{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }}
{{ if site.Params.hotlinkFeatureImage }}
{{ $featuredURL = . }}
{{ else }}
{{ $featured = resources.GetRemote . }}
{{ end }}
{{ else }}
{{ $featured = page.Resources.Get . }}
{{ if not $featured }}
{{ $featured = resources.Get . }}
{{ end }}
{{ end }}
{{ end }}
{{ if not (or $featured $featuredURL) }}
{{ $images := $.Resources.ByType "image" }}
{{ range slice "*feature*" "*cover*" "*thumbnail*" "*background*" }}
{{ if not $featured }}{{ $featured = $images.GetMatch . }}{{ end }}
{{ end }}
{{ end }}
{{ if not (or $featured $featuredURL) }}
{{ $default := site.Store.Get "defaultFeaturedImage" }}
{{ if $default.url }}
{{ $featuredURL = $default.url }}
{{ else if $default.obj }}
{{ $featured = $default.obj }}
{{ end }}
{{ end }}
{{/* generate image URL if not hotlink */}}
{{ if not $featuredURL }}
{{ with $featured }}
{{ $featuredURL = .RelPermalink }}
{{ if not (or $disableImageOptimization (eq .MediaType.SubType "svg")) }}
{{ $size := site.Store.Get "backgroundImageWidth" }}
{{ $featuredURL = (partial "functions/resize.html" (dict "resource" . "spec" $size)).RelPermalink }}
{{ end }}
{{ end }}
{{ end }}
{{ $scope := .Scratch.Get "scope" }}
{{ $shouldBlur := $.Params.layoutBackgroundBlur | default (or
(and ($.Site.Params.article.layoutBackgroundBlur | default true) (eq $scope "single"))
(and ($.Site.Params.list.layoutBackgroundBlur | default true) (eq $scope "list"))
(and ($.Site.Params.taxonomy.layoutBackgroundBlur | default true) (eq $scope "terms"))
(and ($.Site.Params.term.layoutBackgroundBlur | default true) (eq $scope "term"))
)
}}
{{ with $featuredURL }}
<div class="overflow-hidden rounded-md h-36 md:h-56 lg:h-72 nozoom">
<img
src="{{ . }}"
role="presentation"
loading="eager"
decoding="async"
fetchpriority="high"
class="w-full h-full nozoom object-cover"
{{ with $.Params.imagePositionFeature }}style="object-position: {{ . }};"{{ end }} />
</div>
{{ end }}
{{/* When the site-wide background canvas is active and this hero has no
background image of its own, skip the fixed backdrop so the canvas shows
through instead of the fade-to-neutral gradients. */}}
{{ if or $backgroundURL (not (site.Params.backgroundCanvas | default false)) }}
{{ $.Store.Set "suppressBackgroundCanvas" true }}
<div class="single_hero_background nozoom fixed inset-x-0 top-0 h-[800px]">
{{ with $backgroundURL }}
{{ $style := "" }}
{{ $defaultPosition := cond $useDefault site.Params.imagePosition false }}
{{ with $.Params.imagePosition | default $defaultPosition }}
{{ $style = printf "object-position: %s;" . }}
{{ end }}
<img
id="background-image-main"
src="{{ . }}"
role="presentation"
loading="eager"
decoding="async"
fetchpriority="high"
class="absolute inset-0 h-full w-full object-cover"
{{ if $style }}style="{{ $style | safeCSS }}"{{ end }} />
{{ end }}
<div
class="from-neutral absolute inset-0 bg-gradient-to-t to-transparent mix-blend-normal dark:from-neutral-800"></div>
<div
class="from-neutral to-neutral absolute inset-0 bg-gradient-to-t opacity-30 mix-blend-normal dark:from-neutral-800 dark:to-neutral-800 dark:opacity-60"></div>
</div>
{{ end }}
{{ if $shouldBlur | default false }}
<div
id="background-blur"
class="fixed opacity-0 inset-x-0 top-0 h-full single_hero_background nozoom backdrop-blur-xl bg-neutral-100/75 dark:bg-neutral-800/60"></div>
{{ $backgroundBlur := resources.Get "js/background-blur.js" }}
{{ $backgroundBlur = $backgroundBlur | resources.Minify | resources.Fingerprint (.Site.Params.fingerprintAlgorithm | default "sha512") }}
<script
type="text/javascript"
src="{{ $backgroundBlur.RelPermalink }}"
integrity="{{ $backgroundBlur.Data.Integrity }}"
data-blur-id="background-blur"
data-image-id="background-image-main"
{{ with $background }}data-image-url="{{ .RelPermalink }}"{{ end }}></script>
{{ end }}