From 6b8c6c2f46ee8aa0087a67cf2a0ef96696082358 Mon Sep 17 00:00:00 2001 From: Thomas Staudinger Date: Thu, 3 Oct 2024 00:28:16 +0200 Subject: [PATCH 1/2] blog: Use standard summaryLength or explicit summary length (if set) Signed-off-by: Thomas Staudinger --- config.toml | 1 + themes/blog/layouts/blog/list.html | 14 +++++--------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/config.toml b/config.toml index 5106ef1..606aeb4 100755 --- a/config.toml +++ b/config.toml @@ -14,6 +14,7 @@ defaultContentLanguageInSubdir = false googleanalytics = "UA-Not-Yet" metaDataFormat = "toml" pagination.pagerSize = 5 +summaryLength = 25 theme = ["blog", "solus"] enableInlineShortcodes = true diff --git a/themes/blog/layouts/blog/list.html b/themes/blog/layouts/blog/list.html index 5cf3b97..a746d05 100755 --- a/themes/blog/layouts/blog/list.html +++ b/themes/blog/layouts/blog/list.html @@ -8,16 +8,12 @@
{{ partial "blog/info.html" (dict "blog" $firstBlog "site" .Site) }} - {{ if ge (len $firstBlog.Summary) 397 }} -

{{- htmlUnescape (plainify (safeHTML (substr $firstBlog.Summary 0 187))) -}}...

- {{ else }} -

{{- htmlUnescape (plainify (safeHTML $firstBlog.Summary)) -}}

- {{ end }} -
{{ $url := (printf "%s/%s" $firstBlog.Params.url $firstBlog.Params.featuredimage) | absURL }} {{ $firstBlog.Title }} From 1ffbec86e9da93d2ef1e0cdba50d9a5603db3afc Mon Sep 17 00:00:00 2001 From: Thomas Staudinger Date: Tue, 10 Dec 2024 21:51:57 +0100 Subject: [PATCH 2/2] blog: Split summaries into paragraphs so they're properly (un)formatted Except for paragraph splits Signed-off-by: Thomas Staudinger --- themes/blog/layouts/blog/list.html | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/themes/blog/layouts/blog/list.html b/themes/blog/layouts/blog/list.html index a746d05..9832e1e 100755 --- a/themes/blog/layouts/blog/list.html +++ b/themes/blog/layouts/blog/list.html @@ -8,12 +8,19 @@
{{ partial "blog/info.html" (dict "blog" $firstBlog "site" .Site) }} -
{{- safeHTML $firstBlog.Summary -}}
- + + {{ $summaryParagraphs := split $firstBlog.Summary "

" }} + {{range $summaryParagraphs }} + {{ if eq . "" }} + {{ continue }} + {{ end }} +

{{ htmlUnescape (plainify (safeHTML .)) }}

+ {{end}} +
{{ $url := (printf "%s/%s" $firstBlog.Params.url $firstBlog.Params.featuredimage) | absURL }} {{ $firstBlog.Title }}