🥅 Catch any cases where resources don't exist

pull/2/head
James Panther 2021-08-16 14:04:56 +10:00
parent b114f3be73
commit 5575d2b43e
No known key found for this signature in database
GPG Key ID: D36F789E45745D17
3 changed files with 28 additions and 14 deletions

View File

@ -1,15 +1,23 @@
{{ define "main" }} {{ define "main" }}
{{ partial "section-heading.html" . }} {{ partial "section-heading.html" . }}
<section> {{ if gt .Pages 0 }}
{{ range (.Paginate (.Pages.GroupByDate "2006")).PageGroups }} <section>
{{ if $.Site.Params.list.groupByYear }} {{ range (.Paginate (.Pages.GroupByDate "2006")).PageGroups }}
<h2 class="mt-12 text-2xl font-bold first:mt-8">{{ .Key }}</h2> {{ if $.Site.Params.list.groupByYear }}
<hr class="border-gray-400 border-dotted w-36" /> <h2 class="mt-12 text-2xl font-bold first:mt-8">{{ .Key }}</h2>
<hr class="border-gray-400 border-dotted w-36" />
{{ end }}
{{ range .Pages }}
{{ partial "article-link.html" . }}
{{ end }}
{{ end }} {{ end }}
{{ range .Pages }} </section>
{{ partial "article-link.html" . }} {{ partial "pagination.html" . }}
{{ end }} {{ else }}
{{ end }} <section class="mt-10 prose dark:prose-light">
</section> <p class="py-8 border-t">
{{ partial "pagination.html" . }} <em>There's no articles to list here yet.</em>
</p>
</section>
{{ end }}
{{ end }} {{ end }}

View File

@ -1,4 +1,6 @@
<span class="relative inline-block align-text-bottom icon"> <span class="relative inline-block align-text-bottom icon">
{{ $icon := resources.Get (print "icons/" . ".svg") }} {{ $icon := resources.Get (print "icons/" . ".svg") }}
{{ $icon.Content | safeHTML }} {{ if $icon }}
{{ $icon.Content | safeHTML }}
{{ end }}
</span> </span>

View File

@ -1,4 +1,8 @@
<span class="relative inline-block align-text-bottom icon"> <span class="relative inline-block align-text-bottom icon">
{{ $icon := resources.Get (print "icons/" . ".svg") }} {{ $icon := resources.Get (printf "icons/%s.svg" ($.Get 0)) }}
{{ $icon.Content | safeHTML }} {{ if $icon }}
{{ $icon.Content | safeHTML }}
{{ else }}
<em>Icon not found.</em>
{{ end }}
</span> </span>