diff --git a/src/main/engine/PageRenderer.ts b/src/main/engine/PageRenderer.ts index f72af50..6934000 100644 --- a/src/main/engine/PageRenderer.ts +++ b/src/main/engine/PageRenderer.ts @@ -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, diff --git a/src/main/engine/templates/post-list.liquid b/src/main/engine/templates/post-list.liquid index 17ccfa3..669805f 100644 --- a/src/main/engine/templates/post-list.liquid +++ b/src/main/engine/templates/post-list.liquid @@ -38,7 +38,11 @@ {% for post in day_block.posts %}
{% if post.show_title %} -

{{ post.title }}

+ {% 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 %} +

{{ post.title }}

{% endif %} {{ post.content | markdown: post.id, canonical_post_path_by_slug, canonical_media_path_by_source_path, language }}
@@ -49,7 +53,11 @@ {% for post in day_block.posts %}
{% if post.show_title %} -

{{ post.title }}

+ {% 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 %} +

{{ post.title }}

{% endif %} {{ post.content | markdown: post.id, canonical_post_path_by_slug, canonical_media_path_by_source_path, language }}
diff --git a/tests/engine/BlogGenerationEngine.test.ts b/tests/engine/BlogGenerationEngine.test.ts index d43dde8..f1fac95 100644 --- a/tests/engine/BlogGenerationEngine.test.ts +++ b/tests/engine/BlogGenerationEngine.test.ts @@ -251,6 +251,7 @@ describe('BlogGenerationEngine', () => { expect(indexHtml).toContain('href="/"'); expect(indexHtml).toContain('href="/about/"'); expect(indexHtml).toContain('href="/category/news/"'); + expect(indexHtml).toContain('

Hello World

'); expect(indexHtml).toContain('class="blog-menu-submenu"'); const listH1Index = indexHtml.indexOf('

{ await server.start(0); const html = await (await fetch(`${server.getBaseUrl()}/`)).text(); - expect(html).toContain('

Article Title

'); + expect(html).toContain('

Article Title

'); expect(html).not.toContain('

article

'); });