From 7afb18671b5d5460b1d7d75a4e52dfacc7544c44 Mon Sep 17 00:00:00 2001 From: Uwe Schmidt Date: Fri, 24 Mar 2023 13:49:09 +0100 Subject: [PATCH] Respect `showDate` in search results Also hide date for list pages, which don't have their date shown in the theme. --- assets/js/search.js | 2 +- layouts/_default/index.json | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/assets/js/search.js b/assets/js/search.js index 8e331fa52..e5f88047d 100644 --- a/assets/js/search.js +++ b/assets/js/search.js @@ -140,7 +140,7 @@ function executeQuery(term) {
${value.item.title}
-
${value.item.section}·${value.item.date}
+
${value.item.section}${value.item.date == null ? '' : `·${value.item.date}`}
${value.item.summary}
diff --git a/layouts/_default/index.json b/layouts/_default/index.json index d431d3d7c..20e328a48 100644 --- a/layouts/_default/index.json +++ b/layouts/_default/index.json @@ -1,8 +1,9 @@ {{- $index := slice -}} {{- range .Site.Pages -}} {{- $section := .Site.GetPage "section" .Section -}} + {{- $showDate := .Params.showDate | default .Site.Params.article.showDate -}} {{- $index = $index | append (dict - "date" (.Date | time.Format (.Site.Language.Params.dateFormat | default ":date_long")) + "date" (cond (and .IsPage $showDate) (.Date | time.Format (.Site.Language.Params.dateFormat | default ":date_long")) nil) "title" (.Title | emojify | safeJS) "section" ($section.Title | emojify | safeJS) "summary" (.Summary | emojify | safeJS)