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
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
"check": "pnpm lint && pnpm typecheck && pnpm test"
},
"dependencies": {
"@astrojs/cloudflare": "14.4.6",
"@cloudhal/astro-renderer": "0.10.1",
"@cloudhal/cli": "0.10.1",
"@cloudhal/cloudflare": "0.10.1",
"@cloudhal/core-contracts": "0.10.1",
"@cloudhal/core-ts": "0.10.1",
"@astrojs/cloudflare": "14.4.9",
"@cloudhal/astro-renderer": "0.11.0",
"@cloudhal/cli": "0.11.0",
"@cloudhal/cloudflare": "0.11.0",
"@cloudhal/core-contracts": "0.11.0",
"@cloudhal/core-ts": "0.11.0",
"@tailwindcss/vite": "4.3.3",
"astro": "7.4.7",
"tailwindcss": "4.3.3"
Expand All @@ -35,6 +35,6 @@
"@biomejs/biome": "2.5.15",
"@cloudflare/workers-types": "5.20261007.1",
"typescript": "7.0.2",
"wrangler": "4.158.0"
"wrangler": "4.168.0"
}
}
1,312 changes: 865 additions & 447 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ minimumReleaseAgeExclude:
- "@cloudhal/*"


# The version the monorepo builds and tests sites with (its lockfile); newer releases need a newer wrangler.
# The versions the monorepo builds and tests sites with (its lockfile): newer vite-plugin releases
# need a newer wrangler, and one Vite means Astro and the Cloudflare plugin run the same Vite.
overrides:
"@cloudflare/vite-plugin": 1.67.0
"@cloudflare/vite-plugin": 1.70.2
vite: 8.3.8
3 changes: 2 additions & 1 deletion src/env.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/// <reference types="astro/client" />
declare module "virtual:cloudhal/config" {
const config: import("@cloudhal/astro-renderer").CloudhalRendererConfig;
/** No `dataDir` on the Cloudflare Site Worker; `cloudhal dev` and static builds have it. */
const config: import("@cloudhal/astro-renderer").VirtualCloudhalConfig;
export default config;
}
9 changes: 8 additions & 1 deletion src/pages/[...path].astro
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import {
siteOrigin,
withStructuredData,
} from "@cloudhal/astro-renderer/seo";
import { statusPage } from "@cloudhal/astro-renderer/status-page";
import { loadSurfaceSources, surfaceSources } from "@cloudhal/astro-renderer/surfaces";
import {
entryTaxonomy,
Expand Down Expand Up @@ -113,8 +114,14 @@ export async function getStaticPaths() {
}));
}

// RFC-0043 §1.8 (#167): after a page threw, Astro renders this catch-all as its error route
// (`/500` matches it) with the original path. Throw again: Astro then answers an empty 500 that
// the Site Worker turns into the `error` page with a reference, instead of this route's 404.
const renderError = (Astro.props as { error?: unknown }).error;
if (renderError !== undefined) throw renderError;
const source = await getSource(config, Astro);
if (!source) return new Response("This site has not been published yet.", { status: 503 });
// RFC-0043 §1.8: on Cloudflare and in dev the renderer answers before this; the fallback is its page.
if (!source) return statusPage("not-published", { locale: "en", now: Date.now() });
const site = await source.site();
const requested = Astro.params.path ? `/${Astro.params.path}` : "/";
// RFC-0033 §4: the locale is in the path prefix or the host; a non-canonical locale URL moves.
Expand Down
3 changes: 2 additions & 1 deletion src/pages/[...path]/llms.txt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { llmsTxt } from "@cloudhal/astro-renderer/locale-feeds";
import { localeRequest } from "@cloudhal/astro-renderer/locales";
import { getSource } from "@cloudhal/astro-renderer/runtime";
import { siteOrigin } from "@cloudhal/astro-renderer/seo";
import { statusPlain } from "@cloudhal/astro-renderer/status-page";
import type { APIRoute } from "astro";

/** Static builds: `/<locale>/llms.txt` for every other locale served on this host. */
Expand All @@ -23,7 +24,7 @@ export async function getStaticPaths() {
export const GET: APIRoute = async ({ request, url, params }) => {
const headers = new Headers();
const source = await getSource(config, { request, response: { headers } });
if (!source) return new Response("This site has not been published yet.", { status: 503 });
if (!source) return statusPlain("not-published", { locale: "en", now: Date.now() }, "text");
const site = await source.site();
const lr = localeRequest(site, url.host, `/${params.path ?? ""}`);
if (lr.path !== "/") return new Response(null, { status: 404 });
Expand Down
3 changes: 2 additions & 1 deletion src/pages/[...path]/rss.xml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { loadAssetIndex } from "@cloudhal/astro-renderer/media";
import { resolveRoute, staticPaths } from "@cloudhal/astro-renderer/routing";
import { getSource } from "@cloudhal/astro-renderer/runtime";
import { siteOrigin } from "@cloudhal/astro-renderer/seo";
import { statusPlain } from "@cloudhal/astro-renderer/status-page";
import type { APIRoute } from "astro";
import { ARCHIVE_PAGE_SIZE } from "../../theme.ts";

Expand Down Expand Up @@ -46,7 +47,7 @@ export async function getStaticPaths() {
export const GET: APIRoute = async ({ request, url, params }) => {
const headers = new Headers();
const source = await getSource(config, { request, response: { headers } });
if (!source) return new Response("This site has not been published yet.", { status: 503 });
if (!source) return statusPlain("not-published", { locale: "en", now: Date.now() }, "text");
const site = await source.site();
const origin = siteOrigin(site, url);
const lr = localeRequest(site, url.host, `/${params.path ?? ""}`);
Expand Down
3 changes: 2 additions & 1 deletion src/pages/llms.txt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import { llmsTxt } from "@cloudhal/astro-renderer/locale-feeds";
import { hostLocale } from "@cloudhal/astro-renderer/locales";
import { getSource } from "@cloudhal/astro-renderer/runtime";
import { siteOrigin } from "@cloudhal/astro-renderer/seo";
import { statusPlain } from "@cloudhal/astro-renderer/status-page";
import type { APIRoute } from "astro";

/** `llms.txt` (llmstxt.org) in the host's locale; other locales at `/<locale>/llms.txt` (RFC-0033). */
export const GET: APIRoute = async ({ request, url }) => {
const headers = new Headers();
const source = await getSource(config, { request, response: { headers } });
if (!source) return new Response("This site has not been published yet.", { status: 503 });
if (!source) return statusPlain("not-published", { locale: "en", now: Date.now() }, "text");
const site = await source.site();
headers.set("content-type", "text/plain; charset=utf-8");
addCacheTags(headers, [listCacheTag(site.id)]);
Expand Down
3 changes: 2 additions & 1 deletion src/pages/rss.xml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { localeFeedXml } from "@cloudhal/astro-renderer/locale-feeds";
import { hostLocale } from "@cloudhal/astro-renderer/locales";
import { getSource } from "@cloudhal/astro-renderer/runtime";
import { siteOrigin } from "@cloudhal/astro-renderer/seo";
import { statusPlain } from "@cloudhal/astro-renderer/status-page";
import type { APIRoute } from "astro";

/**
Expand All @@ -13,7 +14,7 @@ import type { APIRoute } from "astro";
export const GET: APIRoute = async ({ request, url }) => {
const headers = new Headers();
const source = await getSource(config, { request, response: { headers } });
if (!source) return new Response("This site has not been published yet.", { status: 503 });
if (!source) return statusPlain("not-published", { locale: "en", now: Date.now() }, "text");
const site = await source.site();
headers.set("content-type", "application/rss+xml; charset=utf-8");
// Lists every collection's newest entries: any entry change purges it (`cloudhal-list-<site>`).
Expand Down
3 changes: 2 additions & 1 deletion src/pages/sitemap.xml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { sitemapXml } from "@cloudhal/astro-renderer/feeds";
import { localizedSitemap } from "@cloudhal/astro-renderer/locale-feeds";
import { getSource } from "@cloudhal/astro-renderer/runtime";
import { siteOrigin } from "@cloudhal/astro-renderer/seo";
import { statusPlain } from "@cloudhal/astro-renderer/status-page";
import type { APIRoute } from "astro";

/**
Expand All @@ -13,7 +14,7 @@ import type { APIRoute } from "astro";
export const GET: APIRoute = async ({ request, url }) => {
const headers = new Headers();
const source = await getSource(config, { request, response: { headers } });
if (!source) return new Response("This site has not been published yet.", { status: 503 });
if (!source) return statusPlain("not-published", { locale: "en", now: Date.now() }, "text");
const site = await source.site();
headers.set("content-type", "application/xml; charset=utf-8");
// Lists every page, entry and indexable archive: any entry or term change purges it.
Expand Down