images, deterministic caching

This commit is contained in:
2024-12-03 22:01:12 +00:00
parent fa262d3098
commit 0634e7a3f7
8 changed files with 62 additions and 22 deletions

View File

@@ -0,0 +1,7 @@
{{ $hook_ctx := . }}
{{ with .Page.Resources.Get .Destination | resources.Copy (replaceRE "([^/]*)$" "_$1" (path.Join .Page.Path .Destination)) | fingerprint }}
<figure>
<a href="{{ .RelPermalink }}"><img src="{{ .RelPermalink }}"></a>
{{- with $hook_ctx.Text }}<figcaption>{{ . }}</figcaption>{{ end -}}
</figure>
{{ end }}

View File

@@ -5,11 +5,15 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- prettier-ignore -->
<title>{{ if not .IsHome }}{{ .LinkTitle | humanize }} - {{ end }}{{ .Site.Title }}</title>
{{ $opts := dict "transpiler" "libsass" "targetPath" "style.css" }}
{{ $opts := dict "transpiler" "libsass" "targetPath" "_style._c.css" }}
{{ with resources.Get "css/index.scss" | toCSS $opts | minify | fingerprint }}
<link rel="stylesheet" href="{{ .RelPermalink }}" integrity="{{ .Data.Integrity }}" />
{{ end }}
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
{{ range resources.Match "favicon/*.png" }}
{{ with resources.Copy (printf "_favicon%d._c.png" .Width) . }}
<link rel="shortcut icon" type="image/png" sizes="{{ .Width }}x{{ .Height }}" href="{{ .RelPermalink }}">
{{ end }}
{{ end }}
{{ with .OutputFormats.Get "rss" -}}
{{ printf `<link rel=%q type=%q href=%q title=%q>` .Rel .MediaType.Type .Permalink site.Title | safeHTML }}
{{ end }}

View File

@@ -4,10 +4,12 @@
<div class="about-container">
<div class="about-block">
<div class="image-container">
<img
src="{{ .Params.image.link }}"
{{ print "style" "=" "\"" "aspect-ratio:" .Params.image.ratio "\"" | safeHTMLAttr }}
{{ with resources.Get .Params.image | fingerprint }}
<img
src="{{ .RelPermalink }}"
{{ print "style" "=" "\"" "aspect-ratio:" (print .Width "/" .Height) "\"" | safeHTMLAttr }}
/>
{{ end }}
</div>
<div class="info-container">
<h1>{{ .Title }}</h1>
@@ -22,7 +24,7 @@
</div>
<div class="links">
{{- range .Params.links -}}
<a href="{{ .link | safeURL }}" class="icon-a-wrapper">{{- partial "icon.html" .icon -}}{{- print "" -}}</a>
<a href="{{ .url | safeURL }}" class="icon-a-wrapper" target="_blank">{{- partial "icon.html" .icon -}}{{- print "" -}}</a>
{{- end -}}
</div>
</div>