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 --- exampleSite/config.toml | 1 + layouts/blog/list.html | 35 +++++++++++++++++++---------------- layouts/partials/blog/archive.html | 18 ++++++++++++++++++ layouts/partials/home/blog.html | 28 +++++++++++++++++----------- 4 files changed, 55 insertions(+), 27 deletions(-) create mode 100644 layouts/partials/blog/archive.html diff --git a/exampleSite/config.toml b/exampleSite/config.toml index 8dd59fc..7ed86db 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -20,6 +20,7 @@ DefaultContentLanguage = "en" # Default language fo introHeight = "fullheight" # Input either "medium" or "large" or "fullheight" showLatest = true # Show latest blog post summary showAllPosts = false # Set true to list all posts on home page, or set false to link to separate blog list page + allPostsArchiveFormat = true # show all posts in an archive format numberOfProjectsToShow = 3 # Maximum number of projects to show on home page. Unset or comment out to show all projects localTime = true # Show your current local time in contact section timeZone = "America/Los_Angeles" # Your timezone as in the TZ* column of this list: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones 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