From 77f6e16d9a72cc5166190a19c8adff0652eac330 Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Tue, 19 Sep 2023 16:05:17 -0700 Subject: [PATCH] Fix the IsSet warning when building the site --- layouts/partials/photos/thumbnail.html | 24 ++++++++++++++++++++---- layouts/partials/table_of_contents.html | 2 +- layouts/photos/atom_entry.atom | 2 +- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/layouts/partials/photos/thumbnail.html b/layouts/partials/photos/thumbnail.html index dbd9e1f..831c669 100644 --- a/layouts/partials/photos/thumbnail.html +++ b/layouts/partials/photos/thumbnail.html @@ -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 }} diff --git a/layouts/partials/table_of_contents.html b/layouts/partials/table_of_contents.html index e6fa931..f1dcb62 100644 --- a/layouts/partials/table_of_contents.html +++ b/layouts/partials/table_of_contents.html @@ -1,4 +1,4 @@ -{{ if and (gt .WordCount 400) (isset .Params "toc") .Params.toc }} +{{ if and (gt .WordCount 400) (.Params.toc | default false) }}