From f7d02ea440684931b68b18011f9de75d800f09f2 Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Fri, 27 May 2022 16:24:27 +0200 Subject: Do not show "Latest Publications" if there are no publications --- CHANGELOG.md | 2 ++ layouts/_default/list.atom.xml | 3 ++- layouts/_default/list.feed.xml | 3 ++- layouts/_default/list.json.json | 3 ++- layouts/index.html | 9 +++++++-- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f0c636d..37d2fe4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Amend documentation +- Do not show "Latest Publications" section at the homepage if there are no publications +- Add fallback if main sections are not configured ## v0.1.0 - 2022-05-27 diff --git a/layouts/_default/list.atom.xml b/layouts/_default/list.atom.xml index b3b375d..bd1f982 100644 --- a/layouts/_default/list.atom.xml +++ b/layouts/_default/list.atom.xml @@ -3,7 +3,8 @@ {{- $pages := slice -}} {{- if $.IsHome -}} - {{- $pages = where $pctx.RegularPages.ByDate.Reverse "Type" "in" site.Params.mainSections -}} + {{- $mainSections := site.Params.mainSections | default (slice "post") }} + {{- $pages = where $pctx.RegularPages.ByDate.Reverse "Type" "in" $mainSections -}} {{- else if $.IsSection -}} {{- $pages = $pctx.RegularPages.ByDate.Reverse -}} {{- else -}} diff --git a/layouts/_default/list.feed.xml b/layouts/_default/list.feed.xml index 0a37e09..87d62cc 100644 --- a/layouts/_default/list.feed.xml +++ b/layouts/_default/list.feed.xml @@ -3,7 +3,8 @@ {{- $pages := slice -}} {{- if $.IsHome -}} - {{- $pages = where $pctx.RegularPages.ByDate.Reverse "Type" "in" site.Params.mainSections -}} + {{- $mainSections := site.Params.mainSections | default (slice "post") }} + {{- $pages = where $pctx.RegularPages.ByDate.Reverse "Type" "in" $mainSections -}} {{- else if $.IsSection -}} {{- $pages = $pctx.RegularPages.ByDate.Reverse -}} {{- else -}} diff --git a/layouts/_default/list.json.json b/layouts/_default/list.json.json index bfcb852..308bd96 100644 --- a/layouts/_default/list.json.json +++ b/layouts/_default/list.json.json @@ -3,7 +3,8 @@ {{- $pages := slice -}} {{- if $.IsHome -}} - {{- $pages = where $pctx.RegularPages.ByDate.Reverse "Type" "in" site.Params.mainSections -}} + {{- $mainSections := site.Params.mainSections | default (slice "post") }} + {{- $pages = where $pctx.RegularPages.ByDate.Reverse "Type" "in" $mainSections -}} {{- else if $.IsSection -}} {{- $pages = $pctx.RegularPages.ByDate.Reverse -}} {{- else -}} diff --git a/layouts/index.html b/layouts/index.html index f0f88ae..7dde6eb 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -1,22 +1,27 @@ {{ define "main" }} +{{- $mainSections := site.Params.mainSections | default (slice "post") }} {{- with .Content }}
{{ . }}
+ {{- $section := where site.RegularPages "Section" "in" $mainSections }} + {{- $section_count := len $section }} + {{- if ge $section_count 1 }}
{{/* TODO: Translate me */}}

Latest Publications

+ {{ end }} {{- else }} - {{ $paginator := .Paginate (where site.RegularPages "Type" "in" site.Params.mainSections) }} + {{ $paginator := .Paginate (where site.RegularPages "Section" "in" $mainSections) }}
{{ with .Title }}

{{ . }}

{{ end }} {{ range $paginator.Pages }}{{- .Render "teaser" }}{{ end }} -- cgit v1.2.3