Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/entry-path-one-argument.md
Original file line number Diff line number Diff line change
@@ -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).
5 changes: 3 additions & 2 deletions packages/cloudflare/test/comments.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
19 changes: 17 additions & 2 deletions packages/core-ts/src/permalinks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<ContentEntry, "collection" | "slug">;

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<ContentEntry, "collection" | "slug">,
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}`;
}

Expand Down
5 changes: 5 additions & 0 deletions packages/core-ts/test/permalinks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"]);
});
});
Loading