From 0b92b5cd388cd62a5e59b45847b26095a093ad96 Mon Sep 17 00:00:00 2001 From: Paul Duncan <pabs@pablotron.org> Date: Sat, 16 Oct 2021 10:08:47 -0400 Subject: hugo-pt2021: handle empty article list --- themes/hugo-pt2021/layouts/articles/list.html | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'themes') diff --git a/themes/hugo-pt2021/layouts/articles/list.html b/themes/hugo-pt2021/layouts/articles/list.html index 8db3f26..f9c747b 100644 --- a/themes/hugo-pt2021/layouts/articles/list.html +++ b/themes/hugo-pt2021/layouts/articles/list.html @@ -3,6 +3,9 @@ {{- end -}} {{- define "main" -}} + {{/* get visible articles */}} + {{- $rows := union (where .Pages "Params.show" true) (where .Pages "Params.show" nil) -}} + <div class='container'> <div class='section is-small'> <h1 class='title' title='{{.Title}}' aria-label='{{.Title}}'> @@ -11,18 +14,18 @@ <div class='content'> <ul> - {{- range .Pages -}} - {{- if default true .Params.show -}} - <li> - <a - href='{{.Permalink}}' - title='{{.Title}}' - aria-label='{{.Title}}' - > - {{- .Title -}} - </a> - </li> - {{- end -}} + {{- range $rows.ByTitle -}} + <li> + <a + href='{{.Permalink}}' + title='{{.Title}}' + aria-label='{{.Title}}' + > + {{- .Title -}} + </a> + </li> + {{- else -}} + <li>No articles.</li> {{- end -}} </ul> </div><!-- content --> -- cgit v1.2.3