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 {{- $thumbnailResource := .Page.Resources.GetMatch
(index .Page.Params "thumbnail" | default "[tT]humbnail*") (index .Page.Params "thumbnail" | default "[tT]humbnail*")
| default (index (.Page.Resources.ByType "image") 0) -}} | default (index (.Page.Resources.ByType "image") 0) -}}
@ -9,15 +25,15 @@
{{ $orientation := partial "images/orientation_angle.html" $thumbnailResource }} {{ $orientation := partial "images/orientation_angle.html" $thumbnailResource }}
{{ $targetWidth := 0 }} {{ $targetWidth := 0 }}
{{ if isset . "Width" }} {{ with .Width }}
{{ $targetWidth = .Width }} {{ $targetWidth = . }}
{{ else }} {{ else }}
{{ $targetWidth = $thumbnailResource.Width }} {{ $targetWidth = $thumbnailResource.Width }}
{{ end }} {{ end }}
{{ $targetHeight := 0 }} {{ $targetHeight := 0 }}
{{ if isset . "Height" }} {{ with .Height }}
{{ $targetHeight = .Height }} {{ $targetHeight = . }}
{{ else }} {{ else }}
{{ $targetHeight = $thumbnailResource.Height }} {{ $targetHeight = $thumbnailResource.Height }}
{{ end }} {{ 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"> <aside id="table-of-contents">
<details {{ if eq .Params.toc "open" }}open{{ end }}> <details {{ if eq .Params.toc "open" }}open{{ end }}>
<summary>Table of Contents</summary> <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> <entry>
{{ partial "atom_entry_metadata.xml" . }} {{ partial "atom_entry_metadata.xml" . }}
<link rel="enclosure" href="{{ $thumbnail.Permalink }}" type="{{ $thumbnail.MediaType }}" length="{{ len $thumbnail.Content }}" /> <link rel="enclosure" href="{{ $thumbnail.Permalink }}" type="{{ $thumbnail.MediaType }}" length="{{ len $thumbnail.Content }}" />