summaryrefslogtreecommitdiffstats
path: root/layouts
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-04-05 10:32:37 +0200
committerDanilo M. <danix@danix.xyz>2026-04-05 10:32:37 +0200
commit36fffd8e8dfab639b835e5794b18267c146d231c (patch)
tree55191a62e2c11ab2b6981e31e91cb1410edc9b1b /layouts
parente686b06ea46ae25dba0a40a259f2937b3abf7a7c (diff)
downloaddanixxyz-theme-36fffd8e8dfab639b835e5794b18267c146d231c.tar.gz
danixxyz-theme-36fffd8e8dfab639b835e5794b18267c146d231c.zip
fix: use excerpts instead of full content in article cards
Updated both home.html and section.html to: 1. Check for 'excerpt' field in front matter first 2. If excerpt exists, use it 3. If not, generate from content: get first paragraph, convert to plain text, truncate to 150 characters This prevents full article content from showing in feeds while respecting custom excerpts when provided. Applies to both homepage feed and articles section list view. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Diffstat (limited to 'layouts')
-rw-r--r--layouts/home.html8
-rw-r--r--layouts/section.html7
2 files changed, 13 insertions, 2 deletions
diff --git a/layouts/home.html b/layouts/home.html
index cffb6bc..f285b41 100644
--- a/layouts/home.html
+++ b/layouts/home.html
@@ -12,7 +12,13 @@
{{ range first 6 $articles }}
{{ $type := .Params.type }}
{{ if not $type }}{{ $type = "article" }}{{ end }}
- {{ $data := dict "title" .Title "type" $type "description" .Summary "date" .Date "url" .RelPermalink "image" .Params.image "featured" .Params.featured }}
+
+ {{ $excerpt := .Params.excerpt }}
+ {{ if not $excerpt }}
+ {{ $excerpt = .Summary | plainify | truncate 150 }}
+ {{ end }}
+
+ {{ $data := dict "title" .Title "type" $type "description" $excerpt "date" .Date "url" .RelPermalink "image" .Params.image "featured" .Params.featured }}
{{ partial "post-card.html" $data }}
{{ end }}
{{ end }}
diff --git a/layouts/section.html b/layouts/section.html
index 8b938f3..b9f0646 100644
--- a/layouts/section.html
+++ b/layouts/section.html
@@ -14,7 +14,12 @@
<div class="feed-list" id="articles-feed">
{{ range .Pages.ByDate.Reverse }}
- {{ $data := dict "title" .Title "type" .Params.type "description" .Summary "date" .Date "url" .RelPermalink "image" .Params.image "featured" false }}
+ {{ $excerpt := .Params.excerpt }}
+ {{ if not $excerpt }}
+ {{ $excerpt = .Summary | plainify | truncate 150 }}
+ {{ end }}
+
+ {{ $data := dict "title" .Title "type" .Params.type "description" $excerpt "date" .Date "url" .RelPermalink "image" .Params.image "featured" false }}
{{ partial "post-card.html" $data }}
{{ end }}
</div>