From 740ec93494e60675c1ae5f3cb951f8fb2f3ab051 Mon Sep 17 00:00:00 2001 From: TetraTheta <37061801+TetraTheta@users.noreply.github.com> Date: Thu, 5 Oct 2023 19:04:38 +0900 Subject: [PATCH 1/3] Add summary-truncated class to summary div ... depending on .Truncated --- layouts/partials/hb/modules/blog/post/card.html | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/layouts/partials/hb/modules/blog/post/card.html b/layouts/partials/hb/modules/blog/post/card.html index 94774165..cab4da4e 100644 --- a/layouts/partials/hb/modules/blog/post/card.html +++ b/layouts/partials/hb/modules/blog/post/card.html @@ -31,9 +31,15 @@ {{- end }} {{- if $summary }} -
- {{- default $page.Summary $page.Description -}} -
+ {{- if $page.Truncated }} +
+ {{- default $page.Summary $page.Description -}} +
+ {{- else -}} +
+ {{- default $page.Summary $page.Description -}} +
+ {{- end }} {{- end }} From ffbf178e037344af942e50315675c403014a4add Mon Sep 17 00:00:00 2001 From: TetraTheta <37061801+TetraTheta@users.noreply.github.com> Date: Thu, 5 Oct 2023 19:07:04 +0900 Subject: [PATCH 2/3] Update style for .summary-truncated --- assets/hb/modules/blog/scss/post/_summary.scss | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/assets/hb/modules/blog/scss/post/_summary.scss b/assets/hb/modules/blog/scss/post/_summary.scss index 89a0cf1f..9ebd88df 100644 --- a/assets/hb/modules/blog/scss/post/_summary.scss +++ b/assets/hb/modules/blog/scss/post/_summary.scss @@ -9,3 +9,8 @@ margin-bottom: 0; } } +.summary-truncated { + &::after { + content: "…"; + } +} From b414ea1c8a9f3426c7167c13383379c258140e08 Mon Sep 17 00:00:00 2001 From: Razon Yang Date: Thu, 5 Oct 2023 19:30:46 +0800 Subject: [PATCH 3/3] chore: clean up code --- .../partials/hb/modules/blog/post/card.html | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/layouts/partials/hb/modules/blog/post/card.html b/layouts/partials/hb/modules/blog/post/card.html index cab4da4e..40803b1a 100644 --- a/layouts/partials/hb/modules/blog/post/card.html +++ b/layouts/partials/hb/modules/blog/post/card.html @@ -1,5 +1,5 @@ {{- $page := .Page }} -{{- $summary := default true .Summary }} +{{- $showSummary := default true .Summary }} {{- $readingTime := default true .ReadingTime }} {{- $meta := default true .Meta }}
@@ -30,16 +30,16 @@ {{ partialCached "hb/modules/blog/post/meta/taxonomies" $page $page }}
{{- end }} - {{- if $summary }} - {{- if $page.Truncated }} -
- {{- default $page.Summary $page.Description -}} -
- {{- else -}} -
- {{- default $page.Summary $page.Description -}} -
+ {{- if $showSummary }} + {{- $summary := $page.Summary }} + {{- $truncated := $page.Truncated }} + {{- with $page.Description }} + {{- $summary = . }} + {{- $truncated = false }} {{- end }} +
+ {{- $summary -}} +
{{- end }}