From 5578c0bd0046bee8bcf7afff8a36bbece5091c26 Mon Sep 17 00:00:00 2001 From: firmart Date: Fri, 11 Sep 2020 18:28:08 +0200 Subject: [PATCH 1/2] Show archive only if there is at least one page --- layouts/archive/list.html | 76 ++++++++++++++++++++------------------- 1 file changed, 40 insertions(+), 36 deletions(-) diff --git a/layouts/archive/list.html b/layouts/archive/list.html index 4925349..985f6e4 100644 --- a/layouts/archive/list.html +++ b/layouts/archive/list.html @@ -9,40 +9,44 @@ {{ .Content }} -
-
- {{ $filteredPages := .Site.RegularPages }} - {{ range $.Param "notAllowedTypesInArchive" }} - {{ $filteredPages = (where $filteredPages "Type" "!=" (lower .)) }} - {{ end }} - - {{ $paginator := .Paginate ($filteredPages.GroupByDate ($.Param "archiveGroupByDate" | default "2006")) ($.Param "archivePaginate") }} - - {{ range ($paginator).PageGroups }} - {{ .Key }} -
    - {{ range .Pages }} -
  • - - {{ if ne ($.Param "languagedir") "rtl" }} - {{ .Type }} - {{ .Date.Format (i18n "archive-dateformat") }} - {{ else }} - {{ .Date.Format (i18n "archive-dateformat") }} - {{ .Type }} - {{ end }} - - {{ .Title }} -
  • +{{ if .Pages }} +
    +
    + {{ $filteredPages := .Site.RegularPages }} + {{ range $.Param "notAllowedTypesInArchive" }} + {{ $filteredPages = (where $filteredPages "Type" "!=" (lower .)) }} {{ end }} -
- {{ end }} -
-
- {{ partial "pagination/pagination" . }} -
- {{ partial "search/site-search" . }} -
- {{ partial "script/archive-script" . }} -
-{{ end }} \ No newline at end of file + + {{ $paginator := .Paginate ($filteredPages.GroupByDate ($.Param "archiveGroupByDate" | default "2006")) ($.Param "archivePaginate") }} + + {{ if $paginator }} + {{ range ($paginator).PageGroups }} + {{ .Key }} + + {{ end }} + {{ end }} + +
+ {{ partial "pagination/pagination" . }} +
+ {{ partial "search/site-search" . }} +
+ {{ partial "script/archive-script" . }} + +{{ end }} +{{ end }} From bee8a0bf9efc4105de5a220bda60a9203cc985de Mon Sep 17 00:00:00 2001 From: firmart Date: Sat, 12 Sep 2020 23:58:34 +0200 Subject: [PATCH 2/2] Support (multiple) author(s) as string list --- layouts/partials/body/infos.html | 2 +- layouts/partials/body/whoami.html | 2 +- layouts/partials/head/author.html | 7 +++++++ layouts/partials/summary/card.html | 2 +- layouts/partials/summary/classic.html | 2 +- layouts/partials/summary/compact.html | 2 +- 6 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 layouts/partials/head/author.html diff --git a/layouts/partials/body/infos.html b/layouts/partials/body/infos.html index a80778f..c3ee464 100644 --- a/layouts/partials/body/infos.html +++ b/layouts/partials/body/infos.html @@ -6,7 +6,7 @@ {{ end }}  ·  ☕ {{ .ReadingTime }} {{ i18n "reading-time" }} {{ with .Params.Author }} -  ·  {{if $params.AuthorEmoji }}{{ $params.AuthorEmoji }}{{ else }}✍️{{ end }} {{ . }} +  ·  {{if $params.AuthorEmoji }}{{ $params.AuthorEmoji }}{{ else }}✍️{{ end }} {{ partial "head/author.html" . }} {{ end }} {{ if (and .Site.Params.enableBusuanzi .Site.Params.busuanziPagePV) }} · 👀... {{ i18n "counter-page-pv" }}{{ end }} diff --git a/layouts/partials/body/whoami.html b/layouts/partials/body/whoami.html index 2428dcd..28c8595 100644 --- a/layouts/partials/body/whoami.html +++ b/layouts/partials/body/whoami.html @@ -27,7 +27,7 @@
{{ if $.Param "author" }} - {{ $.Param "author" }} + {{ partial "head/author.html" ($.Param "author") }} {{ else }} {{ $.Param "myname" }} {{ end }} diff --git a/layouts/partials/head/author.html b/layouts/partials/head/author.html new file mode 100644 index 0000000..5a71b59 --- /dev/null +++ b/layouts/partials/head/author.html @@ -0,0 +1,7 @@ +{{ $author_type := (printf "%T" .) }} +{{ $author_is_slice := (eq "[]string" $author_type) }} + {{ if $author_is_slice }} + {{ delimit . ", " }} + {{ else }} + {{ . }} + {{ end }} diff --git a/layouts/partials/summary/card.html b/layouts/partials/summary/card.html index 80e9446..472d3b7 100644 --- a/layouts/partials/summary/card.html +++ b/layouts/partials/summary/card.html @@ -8,7 +8,7 @@ {{ end }} · ☕ {{ .ReadingTime }} {{ i18n "reading-time" }} {{ with $.Param "author" }} - · {{ if $.Param "AuthorEmoji" }}{{ $.Param "AuthorEmoji" }}{{ else }}✍️{{ end }} {{ . }} + · {{ if $.Param "AuthorEmoji" }}{{ $.Param "AuthorEmoji" }}{{ else }}✍️{{ end }} {{ partial "head/author.html" . }} {{ end }} diff --git a/layouts/partials/summary/classic.html b/layouts/partials/summary/classic.html index e43222c..1fde162 100644 --- a/layouts/partials/summary/classic.html +++ b/layouts/partials/summary/classic.html @@ -25,7 +25,7 @@ {{ end }} · ☕ {{ .ReadingTime }} {{ i18n "reading-time" }} {{ with $.Param "author" }} - · {{ if $.Param "authorEmoji" }}{{ $.Param "authorEmoji" }}{{ else }}✍️{{ end }} {{ . }} + · {{ if $.Param "authorEmoji" }}{{ $.Param "authorEmoji" }}{{ else }}✍️{{ end }} {{ partial "head/author.html" . }} {{ end }} diff --git a/layouts/partials/summary/compact.html b/layouts/partials/summary/compact.html index a815fdc..2f4481d 100644 --- a/layouts/partials/summary/compact.html +++ b/layouts/partials/summary/compact.html @@ -11,7 +11,7 @@ {{ end }} · ☕ {{ .ReadingTime }} {{ i18n "reading-time" }} {{ with $params.Author }} - · {{ if $params.AuthorEmoji }}{{ $params.AuthorEmoji }}{{ else }}✍️{{ end }} {{ . }} + · {{ if $params.AuthorEmoji }}{{ $params.AuthorEmoji }}{{ else }}✍️{{ end }} {{ partial "head/author.html" . }} {{ end }}