Fix/post list excerpt rendering (#41)

* feat: use excerpts in post lists

* chore: made testing less noisy

---------

Co-authored-by: hugo <hugoms@me.com>
This commit is contained in:
Georg Bauer
2026-03-07 10:15:57 +01:00
committed by GitHub
parent 9871cb827f
commit f1c9038803
8 changed files with 349 additions and 124 deletions

View File

@@ -1269,6 +1269,17 @@ export class PageRenderer {
return true;
};
const resolveListContent = (post: PostData): string => {
const showTitle = shouldShowListTitle(post);
const excerpt = typeof post.excerpt === 'string' ? post.excerpt.trim() : '';
if (showTitle && excerpt.length > 0) {
return post.excerpt as string;
}
return post.content;
};
const dayBlocks: DayBlockContext[] = [];
if (!options.archiveGrouping) {
@@ -1280,7 +1291,7 @@ export class PageRenderer {
id: post.id,
slug: post.slug,
title: post.title,
content: post.content,
content: resolveListContent(post),
show_title: shouldShowListTitle(post),
})),
});
@@ -1306,7 +1317,7 @@ export class PageRenderer {
id: post.id,
slug: post.slug,
title: post.title,
content: post.content,
content: resolveListContent(post),
show_title: shouldShowListTitle(post),
});
}