diff --git a/.changeset/entry-path-one-argument.md b/.changeset/entry-path-one-argument.md new file mode 100644 index 00000000..72706d6d --- /dev/null +++ b/.changeset/entry-path-one-argument.md @@ -0,0 +1,7 @@ +--- +"@cloudhal/core-ts": patch +"@cloudhal/astro-renderer": patch +"@cloudhal/cli": patch +--- + +Fix: sites whose theme was copied from the starter before 0.3.11 rendered empty pages (200 with no body). Their `EntryList` calls the renderer's old one-argument `entryPath(entry)` (and `.map(entryPath)`), which became `entryPath(site, entry)` in 0.3.11. `entryPath` accepts the old call again (deprecated; it ignores collection permalinks — pass the site to get them). diff --git a/packages/cloudflare/test/comments.test.ts b/packages/cloudflare/test/comments.test.ts index c0859a1b..64f56557 100644 --- a/packages/cloudflare/test/comments.test.ts +++ b/packages/cloudflare/test/comments.test.ts @@ -241,8 +241,9 @@ describe("the hourly comments job (§8.5, §9.3)", () => { T0.toISOString(), ]); - // the snapshots carry the real time: 40 days after T0 the deletion is due - const now = new Date(T0.getTime() + 40 * 86_400_000); + // the snapshots carry the real time, so the deletion is due 40 days after the later of T0 and + // now (a fixed T0 alone stopped being 30 days past the snapshot once the calendar caught up) + const now = new Date(Math.max(T0.getTime(), Date.now()) + 40 * 86_400_000); const r = await runCommentsHourly({ graph, store, now }); expect(r.sites).toBe(1); expect(await store.get(siteId, old)).toBeNull(); diff --git a/packages/core-ts/src/permalinks.ts b/packages/core-ts/src/permalinks.ts index b45af646..618ed9c2 100644 --- a/packages/core-ts/src/permalinks.ts +++ b/packages/core-ts/src/permalinks.ts @@ -25,10 +25,25 @@ export function permalinkPrefix(template: string): string { } /** `/blog/hello-world`: the collection's template with the entry's slug filled in. */ +type EntryRef = Pick; + +export function entryPath(site: PermalinkSite | undefined, entry: EntryRef): string; +/** + * @deprecated The one-argument form of the renderer's old `entryPath(entry)`, kept because themes + * copied from the starter before 0.3.11 call it (also as `entries.map(entryPath)`, which passes + * the index second). It ignores collection permalinks; pass the site. + */ +export function entryPath(entry: EntryRef, index?: number): string; export function entryPath( - site: PermalinkSite | undefined, - entry: Pick, + siteOrEntry: PermalinkSite | EntryRef | undefined, + entry?: EntryRef | number, ): string { + // Old call: no second argument, or a `map` index; the first argument is the entry. + if (typeof entry !== "object" || entry === null) { + const old = siteOrEntry as EntryRef; + return `/${old.collection}/${old.slug}`; + } + const site = siteOrEntry as PermalinkSite | undefined; return `${permalinkPrefix(collectionPermalink(site, entry.collection))}/${entry.slug}`; } diff --git a/packages/core-ts/test/permalinks.test.ts b/packages/core-ts/test/permalinks.test.ts index 603f2cb0..e53ce515 100644 --- a/packages/core-ts/test/permalinks.test.ts +++ b/packages/core-ts/test/permalinks.test.ts @@ -49,4 +49,9 @@ describe("permalinks (RFC-0038)", () => { ]) expect(entryAt(site, entryPath(site, x))).toEqual(x); }); + + it("still answers the old one-argument call of themes copied before 0.3.11", () => { + expect(entryPath(e("posts", "hello"))).toBe("/posts/hello"); + expect([e("posts", "a"), e("news", "b")].map(entryPath)).toEqual(["/posts/a", "/news/b"]); + }); });