From 630c4c6b48344901eef91d6153cba5cae5a2a15a Mon Sep 17 00:00:00 2001 From: Angelo Date: Thu, 24 Dec 2020 21:31:47 +1300 Subject: add archive format to all posts --- layouts/blog/list.html | 35 +++++++++++++++++++---------------- layouts/partials/blog/archive.html | 18 ++++++++++++++++++ layouts/partials/home/blog.html | 28 +++++++++++++++++----------- 3 files changed, 54 insertions(+), 27 deletions(-) create mode 100644 layouts/partials/blog/archive.html (limited to 'layouts') diff --git a/layouts/blog/list.html b/layouts/blog/list.html index 95085c5..d3aea07 100644 --- a/layouts/blog/list.html +++ b/layouts/blog/list.html @@ -5,24 +5,27 @@
{{ if .Site.Params.home.showLatest | default true }}

{{ i18n "index_blog_latestPosts" . }}

- {{ range first 1 .Pages.ByPublishDate.Reverse }} -
{{ if .Params.date }}{{ .Date.Format (.Site.Params.dateFormat | default "Jan 02, 2006") }}{{ end }} -

- - {{ .Title | markdownify }} - -

-
- {{ .Summary }} - {{ if .Truncated }} - {{ i18n "index_blog_readMore" . }} - {{ end }} + {{ range first 1 .Pages.ByPublishDate.Reverse }} +
{{ if .Params.date }}{{ .Date.Format (.Site.Params.dateFormat | default "Jan 02, 2006") }}{{ end }} +

+ + {{ .Title | markdownify }} + +

+
+ {{ .Summary }} + {{ if .Truncated }} + {{ i18n "index_blog_readMore" . }} + {{ end }} +
-
- {{ end }} - + {{ end }} {{ end }}

{{ i18n "index_blog_allPosts" . }}

- {{ partialCached "blog/li.html" . }} + {{if .Site.Params.home.allPostsArchiveFormat}} + {{ partialCached "blog/archive.html" .}} + {{else}} + {{ partialCached "blog/li.html" . }} + {{end}}
{{ end }} diff --git a/layouts/partials/blog/archive.html b/layouts/partials/blog/archive.html new file mode 100644 index 0000000..eaba407 --- /dev/null +++ b/layouts/partials/blog/archive.html @@ -0,0 +1,18 @@ +
+ {{ $prev := 2100}} + {{range .Pages.ByPublishDate.Reverse}} + {{if .Date}} + {{$curr := .Date.Format "2006"}} + {{if gt $prev ($curr)}} +

{{ $curr }}

+ {{end}} +
  • + {{ if .Params.date }} + {{ .Date.Format (.Site.Params.dateFormat | default "Jan 02, 2006") }} - + {{ end }} + {{ .Title | markdownify }} +
  • + {{ $prev = $curr}} + {{end}} + {{end}} +
    diff --git a/layouts/partials/home/blog.html b/layouts/partials/home/blog.html index 0582a20..9f6cd59 100644 --- a/layouts/partials/home/blog.html +++ b/layouts/partials/home/blog.html @@ -16,22 +16,28 @@
    {{ end }} {{ end }} - {{ if .Site.Params.home.showAllPosts }} -
    -
    -

    {{ i18n "index_blog_allPosts" . }}

    - {{ partialCached "blog/li.html" . }} - {{ else }} + {{ if .Site.Params.home.showAllPosts }} +
    +
    +

    {{ i18n "index_blog_allPosts" . }}

    + {{if .Site.Params.home.allPostsArchiveFormat}} + {{ partialCached "blog/archive.html" .}} + {{else}} + {{ partialCached "blog/li.html" . }} + {{end}} +
    +
    + {{ else }} - {{ end }} -
    - - {{ partial "top-icon.html" . }} -
    + {{ end }} + + +{{ partial "top-icon.html" . }} +

    {{ end }} -- cgit v1.2.3