Add a shortcode to embed a photo post in a blog post

This commit is contained in:
Eryn Wells 2022-10-30 11:31:47 -07:00
parent e7b2cb493a
commit 57947282ce
2 changed files with 16 additions and 0 deletions

View file

@ -0,0 +1,8 @@
{{- $thumbnailResource := .Resources.GetMatch (index .Page.Params "thumbnail")
| default (index (.Page.Resources.ByType "image") 0) -}}
{{- if not $thumbnailResource -}}
{{- errorf "No thumbnail available for %s" .Page.Permalink }}
{{- end -}}
{{- $orientation := partial "images/orientation_angle.html" $thumbnailResource -}}
{{- $thumbnail := $thumbnailResource.Fit (printf "%dx%d r%d" .Width .Height (sub 360 $orientation)) -}}
{{ return $thumbnail }}

View file

@ -0,0 +1,8 @@
{{- with $photoPage := $.Page.GetPage (printf "photos/%s" (.Get 0)) -}}
{{- $thumbnail := partial "images/photo_thumbnail.html" (dict "Page" . "Width" 1280 "Height" 1280) -}}
<a href="{{ .RelPermalink }}" title="{{ .Title }}">
<img src="{{ $thumbnail.RelPermalink }}" {{/*{{ with $altText }}alt="{{ . }}"{{ end }}*/}}>
</a>
{{- else -}}
{{- errorf "No page matching '%s'" (.Get 0) -}}
{{- end -}}