From 8b8d3c7fd04c2f4166f7c95c422f55e9de5a535e Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Mon, 25 Nov 2024 19:15:07 -0800 Subject: [PATCH] Implement collapsing consecutive posts in a series Signed-off-by: Danila Fedorin --- assets/scss/style.scss | 14 ++++++++++++++ i18n/en.toml | 3 +++ layouts/index.html | 5 +++-- layouts/partials/post.html | 9 +++++++++ layouts/partials/uniquebyseries.html | 14 ++++++++++++++ 5 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 layouts/partials/uniquebyseries.html diff --git a/assets/scss/style.scss b/assets/scss/style.scss index 719e8b8..356ab52 100755 --- a/assets/scss/style.scss +++ b/assets/scss/style.scss @@ -249,6 +249,20 @@ ul.post-list { text-align: center; margin-bottom: 0.6rem; } + + p.series-link { + margin-top: 1rem; + font-size: 1.1rem; + border-top: $standard-border; + padding-top: 1rem; + + .feather { + fill: none; + width: 1em; + height: 1em; + margin-right: 0.5em; + } + } } .katex-html { diff --git a/i18n/en.toml b/i18n/en.toml index c9bb7b8..b5cc333 100644 --- a/i18n/en.toml +++ b/i18n/en.toml @@ -27,6 +27,9 @@ one = "about one minute to read" other = "about {{ .Count }} minutes to read" +[latestInSeries] + other = "Latest in series:" + [recentPosts] other = "Recent posts" diff --git a/layouts/index.html b/layouts/index.html index ade63a3..66b3443 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -2,9 +2,10 @@ {{ .Content }} {{ i18n "recentPosts" }}: +{{ partial "uniquebyseries.html" (dict "scratch" .Scratch) }} diff --git a/layouts/partials/post.html b/layouts/partials/post.html index 24a5ead..c011b4c 100644 --- a/layouts/partials/post.html +++ b/layouts/partials/post.html @@ -15,4 +15,13 @@

{{ end }}

{{ .page.Summary }} {{ if .page.Truncated }}...{{ end }}

+ {{- if .linkSeries -}} + {{- $term := index (.page.GetTerms "series") 0 -}} + {{- with $term -}} + + {{- end -}} + {{- end }} diff --git a/layouts/partials/uniquebyseries.html b/layouts/partials/uniquebyseries.html new file mode 100644 index 0000000..107b037 --- /dev/null +++ b/layouts/partials/uniquebyseries.html @@ -0,0 +1,14 @@ +{{- $scratch := .scratch -}} +{{- $scratch.Set "pages" slice -}} +{{- $tmpScratch := newScratch -}} +{{- range $post := (where (where site.Pages.ByDate.Reverse "Section" "blog") ".Kind" "!=" "section") -}} +{{- $term := index ($post.GetTerms "series") 0 -}} +{{- if $term -}} +{{- if not ($tmpScratch.Get $term.Permalink) -}} +{{- $tmpScratch.Set $term.Permalink true -}} +{{- $scratch.Add "pages" $post -}} +{{- end -}} +{{- else -}} +{{- $scratch.Add "pages" $post -}} +{{- end -}} +{{- end -}}