From 5575d2b43e26dcc729f75b65cd10e95ff787a57a Mon Sep 17 00:00:00 2001 From: James Panther <4462786+jpanther@users.noreply.github.com> Date: Mon, 16 Aug 2021 14:04:56 +1000 Subject: [PATCH] =?UTF-8?q?=F0=9F=A5=85=20Catch=20any=20cases=20where=20re?= =?UTF-8?q?sources=20don't=20exist?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- layouts/_default/list.html | 30 +++++++++++++++++++----------- layouts/partials/icon.html | 4 +++- layouts/shortcodes/icon.html | 8 ++++++-- 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/layouts/_default/list.html b/layouts/_default/list.html index 1c8b0fbf..e2081674 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -1,15 +1,23 @@ {{ define "main" }} {{ partial "section-heading.html" . }} -
- {{ range (.Paginate (.Pages.GroupByDate "2006")).PageGroups }} - {{ if $.Site.Params.list.groupByYear }} -

{{ .Key }}

-
+ {{ if gt .Pages 0 }} +
+ {{ range (.Paginate (.Pages.GroupByDate "2006")).PageGroups }} + {{ if $.Site.Params.list.groupByYear }} +

{{ .Key }}

+
+ {{ end }} + {{ range .Pages }} + {{ partial "article-link.html" . }} + {{ end }} {{ end }} - {{ range .Pages }} - {{ partial "article-link.html" . }} - {{ end }} - {{ end }} -
- {{ partial "pagination.html" . }} +
+ {{ partial "pagination.html" . }} + {{ else }} +
+

+ There's no articles to list here yet. +

+
+ {{ end }} {{ end }} diff --git a/layouts/partials/icon.html b/layouts/partials/icon.html index 6c532514..cde57b96 100644 --- a/layouts/partials/icon.html +++ b/layouts/partials/icon.html @@ -1,4 +1,6 @@ {{ $icon := resources.Get (print "icons/" . ".svg") }} - {{ $icon.Content | safeHTML }} + {{ if $icon }} + {{ $icon.Content | safeHTML }} + {{ end }} diff --git a/layouts/shortcodes/icon.html b/layouts/shortcodes/icon.html index 6c532514..e9251eac 100644 --- a/layouts/shortcodes/icon.html +++ b/layouts/shortcodes/icon.html @@ -1,4 +1,8 @@ - {{ $icon := resources.Get (print "icons/" . ".svg") }} - {{ $icon.Content | safeHTML }} + {{ $icon := resources.Get (printf "icons/%s.svg" ($.Get 0)) }} + {{ if $icon }} + {{ $icon.Content | safeHTML }} + {{ else }} + Icon not found. + {{ end }}