fix: 0-byte index.html day archives

This commit is contained in:
2026-02-22 15:34:16 +01:00
parent b4109d7210
commit a7e7ae5b1a
8 changed files with 211 additions and 7 deletions

View File

@@ -0,0 +1,34 @@
import { describe, expect, it } from 'vitest';
import { PageRenderer, type HtmlRewriteContext } from '../../src/main/engine/PageRenderer';
const rewriteContext: HtmlRewriteContext = {
canonicalPostPathBySlug: new Map<string, string>(),
canonicalMediaPathBySourcePath: new Map<string, string>(),
};
describe('PageRenderer.renderPostList', () => {
it('renders base framework for empty day archive pages instead of returning empty html', async () => {
const renderer = new PageRenderer(
{ getAllMedia: async () => [] },
{
getLinkedMediaDataForPost: async () => [],
setProjectContext: () => {},
},
);
const html = await renderer.renderPostList([], rewriteContext, {
archiveGrouping: true,
routeKind: 'date',
archiveContext: { kind: 'day', year: 2026, month: 2, day: 22 },
basePathname: '/2026/02/22',
page_title: 'Test Blog',
language: 'en',
menu_items: [],
renderEmptyState: true,
});
expect(html).toContain('<!doctype html>');
expect(html).toContain('<section class="post-list"');
expect(html).toContain('<h1 class="archive-heading">Archive 22. February 2026</h1>');
});
});