Fix the IsSet warning when building the site

This commit is contained in:
Eryn Wells 2023-09-19 16:05:17 -07:00
parent 755de7d938
commit 77f6e16d9a
3 changed files with 22 additions and 6 deletions

View file

@ -1,3 +1,19 @@
{{/*
Renders a photo thumbnail. If neither a target height or target width are
given, and the image is already in the correct orientation, no image
processing is performed.
Arguments
---------
"Page" : A reference to the current Page
"Height" : The target height of the image
"Width" : The target width of the image
Returns
-------
The processed thumbnail image resource
*/}}
{{- $thumbnailResource := .Page.Resources.GetMatch
(index .Page.Params "thumbnail" | default "[tT]humbnail*")
| default (index (.Page.Resources.ByType "image") 0) -}}
@ -9,15 +25,15 @@
{{ $orientation := partial "images/orientation_angle.html" $thumbnailResource }}
{{ $targetWidth := 0 }}
{{ if isset . "Width" }}
{{ $targetWidth = .Width }}
{{ with .Width }}
{{ $targetWidth = . }}
{{ else }}
{{ $targetWidth = $thumbnailResource.Width }}
{{ end }}
{{ $targetHeight := 0 }}
{{ if isset . "Height" }}
{{ $targetHeight = .Height }}
{{ with .Height }}
{{ $targetHeight = . }}
{{ else }}
{{ $targetHeight = $thumbnailResource.Height }}
{{ end }}

View file

@ -1,4 +1,4 @@
{{ if and (gt .WordCount 400) (isset .Params "toc") .Params.toc }}
{{ if and (gt .WordCount 400) (.Params.toc | default false) }}
<aside id="table-of-contents">
<details {{ if eq .Params.toc "open" }}open{{ end }}>
<summary>Table of Contents</summary>

View file

@ -1,4 +1,4 @@
{{- $thumbnail := partial "photos/thumbnail.html" . -}}
{{- $thumbnail := partial "photos/thumbnail.html" (dict "Page" . "Width" nil "Height" nil) -}}
<entry>
{{ partial "atom_entry_metadata.xml" . }}
<link rel="enclosure" href="{{ $thumbnail.Permalink }}" type="{{ $thumbnail.MediaType }}" length="{{ len $thumbnail.Content }}" />