From 9de80ae486bc43c8680fda099a125d836e78b552 Mon Sep 17 00:00:00 2001 From: Alex Dombroski Date: Fri, 12 Jun 2026 11:47:48 -0600 Subject: [PATCH 1/6] feat(cli): Adds wrangler schema to generated wrangler.jsonc file when running `astro add cloudflare` command (#16762) * feat: cloudflare wrangler config includes a schema * feat(docs): add changeset * Tweak changeset --------- Co-authored-by: Chris Swithinbank --- .changeset/shaggy-wolves-serve.md | 5 +++++ packages/astro/src/cli/add/index.ts | 1 + 2 files changed, 6 insertions(+) create mode 100644 .changeset/shaggy-wolves-serve.md diff --git a/.changeset/shaggy-wolves-serve.md b/.changeset/shaggy-wolves-serve.md new file mode 100644 index 000000000000..5c5e4534cc1f --- /dev/null +++ b/.changeset/shaggy-wolves-serve.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Adds a JSON schema to the Wrangler configuration file generated when running `astro add cloudflare` diff --git a/packages/astro/src/cli/add/index.ts b/packages/astro/src/cli/add/index.ts index a09c9fd90550..f53435ef8ec7 100644 --- a/packages/astro/src/cli/add/index.ts +++ b/packages/astro/src/cli/add/index.ts @@ -82,6 +82,7 @@ export default async function seed() { `, CLOUDFLARE_WRANGLER_CONFIG: (name: string, compatibilityDate: string) => `\ { + "$schema": "./node_modules/wrangler/config-schema.json", "compatibility_date": ${JSON.stringify(compatibilityDate)}, "compatibility_flags": ["global_fetch_strictly_public"], "name": ${JSON.stringify(name)}, From 52fc86213e6412b6f9f3b70a2616d52b5fb783a9 Mon Sep 17 00:00:00 2001 From: Martin Heidegger Date: Sat, 13 Jun 2026 02:50:24 +0900 Subject: [PATCH 2/6] Supporting numeric id references (#16672) * fix: supporting numbers in references * Tweak changeset --------- Co-authored-by: Chris Swithinbank --- .changeset/rare-eggs-notice.md | 5 ++ packages/astro/src/content/runtime.ts | 1 + .../content-layer/data-transforms.test.ts | 57 +++++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 .changeset/rare-eggs-notice.md diff --git a/.changeset/rare-eggs-notice.md b/.changeset/rare-eggs-notice.md new file mode 100644 index 000000000000..eb8ba7ab03d9 --- /dev/null +++ b/.changeset/rare-eggs-notice.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fixes support for numeric IDs in YAML frontmatter when using content collection references diff --git a/packages/astro/src/content/runtime.ts b/packages/astro/src/content/runtime.ts index ac57450b8556..2124bc5beda2 100644 --- a/packages/astro/src/content/runtime.ts +++ b/packages/astro/src/content/runtime.ts @@ -686,6 +686,7 @@ export function createReference() { return function reference(collection: string) { return z .union([ + z.number().transform(num => num.toString(10)), z.string(), z.object({ id: z.string(), diff --git a/packages/astro/test/units/content-layer/data-transforms.test.ts b/packages/astro/test/units/content-layer/data-transforms.test.ts index 2b1e8392b51a..41c46b8c892c 100644 --- a/packages/astro/test/units/content-layer/data-transforms.test.ts +++ b/packages/astro/test/units/content-layer/data-transforms.test.ts @@ -514,4 +514,61 @@ describe('Content Layer - Data Transforms', () => { // The default is applied as a string, not transformed to a reference object assert.equal(result2.data.category, 'general'); }); + + it('transforms numeric ids to strings', async () => { + const store = new MutableDataStore(); + const settings = createMinimalSettings(root); + const logger = new AstroLogger({ + destination: { write: () => true }, + level: 'silent', + }); + + // Create a loader that returns data with reference strings + const dogsLoader = { + name: 'dogs-loader', + load: async (context: any) => { + const data = { + id: 'beagle', + name: 'Beagle Dog', + favoriteCat: 1, + }; + + const parsed = await context.parseData({ + id: 'beagle', + data, + }); + + await context.store.set({ + id: 'beagle', + data: parsed, + }); + }, + }; + + const collections = { + dogs: defineCollection({ + loader: dogsLoader, + schema: z.object({ + id: z.string(), + name: z.string(), + favoriteCat: reference('cats'), + }), + }), + }; + + const contentLayer = new ContentLayer({ + settings, + logger, + store, + contentConfigObserver: createTestConfigObserver(collections), + }); + + await contentLayer.sync(); + + const result: any = store.get('dogs', 'beagle'); + assert.ok(result); + assert.equal(result.data.id, 'beagle'); + assert.equal(result.data.name, 'Beagle Dog'); + assert.deepEqual(result.data.favoriteCat, { collection: 'cats', id: '1' }); + }) }); From bbe0e5403193b0cc2141667b65ab66aeebcff725 Mon Sep 17 00:00:00 2001 From: Martin Heidegger Date: Fri, 12 Jun 2026 17:52:08 +0000 Subject: [PATCH 3/6] [ci] format --- packages/astro/src/content/runtime.ts | 2 +- packages/astro/test/units/content-layer/data-transforms.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/astro/src/content/runtime.ts b/packages/astro/src/content/runtime.ts index 2124bc5beda2..7e19afc4f2f5 100644 --- a/packages/astro/src/content/runtime.ts +++ b/packages/astro/src/content/runtime.ts @@ -686,7 +686,7 @@ export function createReference() { return function reference(collection: string) { return z .union([ - z.number().transform(num => num.toString(10)), + z.number().transform((num) => num.toString(10)), z.string(), z.object({ id: z.string(), diff --git a/packages/astro/test/units/content-layer/data-transforms.test.ts b/packages/astro/test/units/content-layer/data-transforms.test.ts index 41c46b8c892c..5aba7cf0eeb8 100644 --- a/packages/astro/test/units/content-layer/data-transforms.test.ts +++ b/packages/astro/test/units/content-layer/data-transforms.test.ts @@ -570,5 +570,5 @@ describe('Content Layer - Data Transforms', () => { assert.equal(result.data.id, 'beagle'); assert.equal(result.data.name, 'Beagle Dog'); assert.deepEqual(result.data.favoriteCat, { collection: 'cats', id: '1' }); - }) + }); }); From c0d16179d17dc81fdd57d879f3a0b5abf1e8fa69 Mon Sep 17 00:00:00 2001 From: Andrei Alba <22475402+andreialba@users.noreply.github.com> Date: Fri, 12 Jun 2026 21:00:37 +0300 Subject: [PATCH 4/6] docs: fix example README links and add missing READMEs (#16844) --- examples/advanced-routing/README.md | 53 ++++++++++++++++++++ examples/component/README.md | 4 +- examples/container-with-vitest/README.md | 4 +- examples/ssr/README.md | 62 ++++++++++++++++++++++++ 4 files changed, 119 insertions(+), 4 deletions(-) create mode 100644 examples/advanced-routing/README.md create mode 100644 examples/ssr/README.md diff --git a/examples/advanced-routing/README.md b/examples/advanced-routing/README.md new file mode 100644 index 000000000000..50fccd164387 --- /dev/null +++ b/examples/advanced-routing/README.md @@ -0,0 +1,53 @@ +# Astro Advanced Routing Example + +```sh +npm create astro@latest -- --template advanced-routing +``` + +[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/withastro/astro/tree/latest/examples/advanced-routing) +[![Open with CodeSandbox](https://assets.codesandbox.io/github/button-edit-lime.svg)](https://codesandbox.io/p/sandbox/github/withastro/astro/tree/latest/examples/advanced-routing) + +This example showcases Astro's experimental advanced routing with `src/app.ts`, using [Hono](https://hono.dev/) middleware to control the request pipeline. + +## 🚀 Project Structure + +Inside of your Astro project, you'll see the following folders and files: + +```text +/ +├── src/ +│ ├── actions/ +│ ├── layouts/ +│ ├── pages/ +│ │ ├── dashboard/ +│ │ └── es/ +│ └── app.ts +├── astro.config.mjs +├── package.json +└── tsconfig.json +``` + +Astro looks for `.astro` or `.md` files in the `src/pages/` directory. Each page is exposed as a route based on its file name. + +The `src/app.ts` file controls the request pipeline. This example composes Astro's middleware with custom Hono middleware to handle routing behavior like authentication, redirects, and locale-specific pages. + +## Server-side rendering (SSR) + +This project uses the [`@astrojs/node`](https://docs.astro.build/en/guides/integrations-guide/node/) adapter with `output: "server"` and enables Astro's experimental `advancedRouting` option. + +## 🧞 Commands + +All commands are run from the root of the project, from a terminal: + +| Command | Action | +| :------------------------ | :----------------------------------------------- | +| `npm install` | Installs dependencies | +| `npm run dev` | Starts local dev server at `localhost:4321` | +| `npm run build` | Build your production site to `./dist/` | +| `npm run preview` | Preview your build locally, before deploying | +| `npm run astro ...` | Run CLI commands like `astro add`, `astro check` | +| `npm run astro -- --help` | Get help using the Astro CLI | + +## 👀 Want to learn more? + +Feel free to check [our documentation](https://docs.astro.build) or jump into our [Discord server](https://astro.build/chat). diff --git a/examples/component/README.md b/examples/component/README.md index f51958529925..808a78e9f8ec 100644 --- a/examples/component/README.md +++ b/examples/component/README.md @@ -6,8 +6,8 @@ This is a template for an Astro component library. Use this template for writing npm create astro@latest -- --template component ``` -[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/withastro/astro/tree/latest/examples/non-html-pages) -[![Open with CodeSandbox](https://assets.codesandbox.io/github/button-edit-lime.svg)](https://codesandbox.io/p/sandbox/github/withastro/astro/tree/latest/examples/non-html-pages) +[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/withastro/astro/tree/latest/examples/component) +[![Open with CodeSandbox](https://assets.codesandbox.io/github/button-edit-lime.svg)](https://codesandbox.io/p/sandbox/github/withastro/astro/tree/latest/examples/component) [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/withastro/astro?devcontainer_path=.devcontainer/component/devcontainer.json) ## 🚀 Project Structure diff --git a/examples/container-with-vitest/README.md b/examples/container-with-vitest/README.md index 116268944c55..df971256a343 100644 --- a/examples/container-with-vitest/README.md +++ b/examples/container-with-vitest/README.md @@ -4,8 +4,8 @@ npm create astro@latest -- --template container-with-vitest ``` -[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/withastro/astro/tree/latest/examples/with-vitest) -[![Open with CodeSandbox](https://assets.codesandbox.io/github/button-edit-lime.svg)](https://codesandbox.io/p/sandbox/github/withastro/astro/tree/latest/examples/with-vitest) +[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/withastro/astro/tree/latest/examples/container-with-vitest) +[![Open with CodeSandbox](https://assets.codesandbox.io/github/button-edit-lime.svg)](https://codesandbox.io/p/sandbox/github/withastro/astro/tree/latest/examples/container-with-vitest) [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/withastro/astro?devcontainer_path=.devcontainer/with-vitest/devcontainer.json) This example showcases Astro working with [Vitest](https://vitest.dev/) and how to test components using the Container API. diff --git a/examples/ssr/README.md b/examples/ssr/README.md new file mode 100644 index 000000000000..c987228f5e65 --- /dev/null +++ b/examples/ssr/README.md @@ -0,0 +1,62 @@ +# Astro SSR Example + +```sh +npm create astro@latest -- --template ssr +``` + +[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/withastro/astro/tree/latest/examples/ssr) +[![Open with CodeSandbox](https://assets.codesandbox.io/github/button-edit-lime.svg)](https://codesandbox.io/p/sandbox/github/withastro/astro/tree/latest/examples/ssr) +[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/withastro/astro?devcontainer_path=.devcontainer/ssr/devcontainer.json) + +This example showcases server-side rendering with Astro using the [`@astrojs/node`](https://docs.astro.build/en/guides/integrations-guide/node/) adapter and [`@astrojs/svelte`](https://docs.astro.build/en/guides/integrations-guide/svelte/) integration. + +## 🚀 Project Structure + +Inside of your Astro project, you'll see the following folders and files: + +```text +/ +├── public/ +│ ├── favicon.ico +│ ├── favicon.svg +│ └── images/ +├── src/ +│ ├── components/ +│ ├── models/ +│ ├── pages/ +│ │ ├── api/ +│ │ └── products/ +│ ├── styles/ +│ └── api.ts +├── astro.config.mjs +├── package.json +└── tsconfig.json +``` + +Astro looks for `.astro` or `.md` files in the `src/pages/` directory. Each page is exposed as a route based on its file name. Dynamic routes like `products/[id].astro` are used to render individual product pages. + +There's nothing special about `src/components/`, but that's where we like to put any Astro or framework components. + +Any static assets, like images, can be placed in the `public/` directory. + +## Server-side rendering (SSR) + +This project uses the [`@astrojs/node`](https://docs.astro.build/en/guides/integrations-guide/node/) adapter with `output: "server"` to render pages on demand and expose API routes from `src/pages/api/`. + +## 🧞 Commands + +All commands are run from the root of the project, from a terminal: + +| Command | Action | +| :------------------------ | :----------------------------------------------- | +| `npm install` | Installs dependencies | +| `npm run dev` | Starts local dev server at `localhost:4321` | +| `npm run build` | Build your production site to `./dist/` | +| `npm run preview` | Preview your build locally, before deploying | +| `npm run server` | Run the built Node server from `./dist/server/` | +| `npm run astro ...` | Run CLI commands like `astro add`, `astro check` | +| `npm run astro -- --help` | Get help using the Astro CLI | + +## 👀 Want to learn more? + +Feel free to check [our documentation](https://docs.astro.build) or jump into our [Discord server](https://astro.build/chat). From 814bf83b7e9542371635d1fd46dcedbf9118a2f2 Mon Sep 17 00:00:00 2001 From: Andreas Deininger Date: Fri, 12 Jun 2026 20:08:03 +0200 Subject: [PATCH 5/6] Fix typos (#16923) Co-authored-by: Chris Swithinbank --- AGENTS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AGENTS.md b/AGENTS.md index 3a8a966fd117..c30c97b651f0 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -116,7 +116,7 @@ Use `pnpm -C ` for project-local script commands when working in # `bgproc` -Use `pnpm exec bgproc` to start, stop, and manage long-running `astro dev` & `astro preview` servers in the background. Do not manually start detatched servers with `&` if you can use `bgproc` instead. +Use `pnpm exec bgproc` to start, stop, and manage long-running `astro dev` & `astro preview` servers in the background. Do not manually start detached servers with `&` if you can use `bgproc` instead. Use `pnpm exec bgproc --help` to see all available commands. From 360fa3f0b97f0b595c3df868dc7f2bcab210d5fe Mon Sep 17 00:00:00 2001 From: dfedoryshchev <64079946+dfedoryshchev@users.noreply.github.com> Date: Fri, 12 Jun 2026 19:09:43 +0100 Subject: [PATCH 6/6] docs: fix grammar in container API JSDoc comments (#16984) --- packages/astro/src/container/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/astro/src/container/index.ts b/packages/astro/src/container/index.ts index 8d47c7a1630d..cec8d137705b 100644 --- a/packages/astro/src/container/index.ts +++ b/packages/astro/src/container/index.ts @@ -96,7 +96,7 @@ export type ContainerRenderOptions = { routeType?: RouteType; /** - * Allows to pass `Astro.props` to an Astro component: + * Allows passing `Astro.props` to an Astro component: * * ```js * container.renderToString(Endpoint, { props: { "lorem": "ipsum" } }); @@ -105,9 +105,9 @@ export type ContainerRenderOptions = { props?: Props; /** - * When `false`, it forces to render the component as it was a full-fledged page. + * When `false`, it forces the component to render as if it were a full-fledged page. * - * By default, the container API render components as [partials](https://docs.astro.build/en/basics/astro-pages/#page-partials). + * By default, the container API renders components as [partials](https://docs.astro.build/en/basics/astro-pages/#page-partials). * */ partial?: boolean;