feat: title links on posts in lists
This commit is contained in:
@@ -15,6 +15,7 @@ export interface HtmlRewriteContext {
|
||||
|
||||
export interface TemplatePostEntry {
|
||||
id: string;
|
||||
slug: string;
|
||||
title: string;
|
||||
content: string;
|
||||
show_title: boolean;
|
||||
@@ -896,6 +897,7 @@ export class PageRenderer {
|
||||
show_separator: false,
|
||||
posts: posts.map((post) => ({
|
||||
id: post.id,
|
||||
slug: post.slug,
|
||||
title: post.title,
|
||||
content: post.content,
|
||||
show_title: shouldShowListTitle(post),
|
||||
@@ -921,6 +923,7 @@ export class PageRenderer {
|
||||
|
||||
currentBlock.block.posts.push({
|
||||
id: post.id,
|
||||
slug: post.slug,
|
||||
title: post.title,
|
||||
content: post.content,
|
||||
show_title: shouldShowListTitle(post),
|
||||
@@ -1074,6 +1077,7 @@ export class PageRenderer {
|
||||
menu_items: pageContext.menu_items ?? [],
|
||||
post: {
|
||||
id: renderablePost.id,
|
||||
slug: renderablePost.slug,
|
||||
title: renderablePost.title,
|
||||
content: renderablePost.content,
|
||||
show_title: false,
|
||||
|
||||
@@ -38,7 +38,11 @@
|
||||
{% for post in day_block.posts %}
|
||||
<div class="post">
|
||||
{% if post.show_title %}
|
||||
<h2 class="post-title">{{ post.title }}</h2>
|
||||
{% assign canonical_post_href = canonical_post_path_by_slug[post.slug] %}
|
||||
{% if canonical_post_href == blank %}
|
||||
{% assign canonical_post_href = '/posts/' | append: post.slug %}
|
||||
{% endif %}
|
||||
<h2 class="post-title"><a href="{{ canonical_post_href }}">{{ post.title }}</a></h2>
|
||||
{% endif %}
|
||||
{{ post.content | markdown: post.id, canonical_post_path_by_slug, canonical_media_path_by_source_path, language }}
|
||||
</div>
|
||||
@@ -49,7 +53,11 @@
|
||||
{% for post in day_block.posts %}
|
||||
<div class="post">
|
||||
{% if post.show_title %}
|
||||
<h2 class="post-title">{{ post.title }}</h2>
|
||||
{% assign canonical_post_href = canonical_post_path_by_slug[post.slug] %}
|
||||
{% if canonical_post_href == blank %}
|
||||
{% assign canonical_post_href = '/posts/' | append: post.slug %}
|
||||
{% endif %}
|
||||
<h2 class="post-title"><a href="{{ canonical_post_href }}">{{ post.title }}</a></h2>
|
||||
{% endif %}
|
||||
{{ post.content | markdown: post.id, canonical_post_path_by_slug, canonical_media_path_by_source_path, language }}
|
||||
</div>
|
||||
|
||||
@@ -251,6 +251,7 @@ describe('BlogGenerationEngine', () => {
|
||||
expect(indexHtml).toContain('href="/"');
|
||||
expect(indexHtml).toContain('href="/about/"');
|
||||
expect(indexHtml).toContain('href="/category/news/"');
|
||||
expect(indexHtml).toContain('<h2 class="post-title"><a href="/2025/03/15/hello-world">Hello World</a></h2>');
|
||||
expect(indexHtml).toContain('class="blog-menu-submenu"');
|
||||
|
||||
const listH1Index = indexHtml.indexOf('<h1 class="archive-heading"');
|
||||
|
||||
@@ -1017,7 +1017,7 @@ describe('PreviewServer', () => {
|
||||
await server.start(0);
|
||||
|
||||
const html = await (await fetch(`${server.getBaseUrl()}/`)).text();
|
||||
expect(html).toContain('<h2 class="post-title">Article Title</h2>');
|
||||
expect(html).toContain('<h2 class="post-title"><a href="/2025/02/06/pt-1">Article Title</a></h2>');
|
||||
expect(html).not.toContain('<h2 class="post-category-title">article</h2>');
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user