diff options
41 files changed, 569 insertions, 280 deletions
diff --git a/.changeset/all-readers-jump.md b/.changeset/all-readers-jump.md deleted file mode 100644 index f6dbe24dd..000000000 --- a/.changeset/all-readers-jump.md +++ /dev/null @@ -1,89 +0,0 @@ ---- -'@astrojs/cloudflare': minor -'@astrojs/netlify': minor -'@astrojs/node': minor -'astro': minor ---- - -The experimental session API introduced in Astro 5.1 is now stable and ready for production use. - -Sessions are used to store user state between requests for [on-demand rendered pages](https://astro.build/en/guides/on-demand-rendering/). You can use them to store user data, such as authentication tokens, shopping cart contents, or any other data that needs to persist across requests: - -```astro ---- -export const prerender = false; // Not needed with 'server' output -const cart = await Astro.session.get('cart'); ---- - -<a href="/checkout">🛒 {cart?.length ?? 0} items</a> -``` - -## Configuring session storage - -Sessions require a storage driver to store the data. The Node, Cloudflare and Netlify adapters automatically configure a default driver for you, but other adapters currently require you to specify a custom storage driver in your configuration. - -If you are using an adapter that doesn't have a default driver, or if you want to choose a different driver, you can configure it using the `session` configuration option: - -```js -import { defineConfig } from 'astro/config'; -import vercel from '@astrojs/vercel'; - -export default defineConfig({ - adapter: vercel(), - session: { - driver: 'upstash', - }, -}); -``` - -## Using sessions - -Sessions are available in on-demand rendered pages, API endpoints, actions and middleware. - -In pages and components, you can access the session using `Astro.session`: - -```astro ---- -const cart = await Astro.session.get('cart'); ---- - -<a href="/checkout">🛒 {cart?.length ?? 0} items</a> -``` - -In endpoints, actions, and middleware, you can access the session using `context.session`: - -```js -export async function GET(context) { - const cart = await context.session.get('cart'); - return Response.json({ cart }); -} -``` - -If you attempt to access the session when there is no storage driver configured, or in a prerendered page, the session object will be `undefined` and an error will be logged in the console: - -```astro ---- -export const prerender = true; -const cart = await Astro.session?.get('cart'); // Logs an error. Astro.session is undefined ---- -``` - -## Upgrading from Experimental to Stable - -If you were previously using the experimental API, please remove the `experimental.session` flag from your configuration: - -```diff -import { defineConfig } from 'astro/config'; -import node from '@astrojs/node'; - -export default defineConfig({ - adapter: node({ - mode: "standalone", - }), -- experimental: { -- session: true, -- }, -}); -``` - -See [the sessions guide](https://docs.astro.build/en/guides/sessions/) for more information. diff --git a/.changeset/happy-spies-punch.md b/.changeset/happy-spies-punch.md deleted file mode 100644 index b61651558..000000000 --- a/.changeset/happy-spies-punch.md +++ /dev/null @@ -1,41 +0,0 @@ ---- -'astro': minor ---- - -Adds a new, experimental Fonts API to provide first-party support for fonts in Astro. - -This experimental feature allows you to use fonts from both your file system and several built-in supported providers (e.g. Google, Fontsource, Bunny) through a unified API. Keep your site performant thanks to sensible defaults and automatic optimizations including fallback font generation. - -To enable this feature, configure an `experimental.fonts` object with one or more fonts: - -```js title="astro.config.mjs" -import { defineConfig, fontProviders } from "astro/config" - -export default defineConfig({ - experimental: { - fonts: [{ - provider: fontProviders.google(), - ` name: "Roboto", - cssVariable: "--font-roboto", - }] - } -}) -``` - -Then, add a `<Font />` component and site-wide styling in your `<head>`: - -```astro title="src/components/Head.astro" ---- -import { Font } from 'astro:assets' ---- -<Font cssVariable='--font-roboto' preload /> -<style> -body { - font-family: var(--font-roboto); -} -</style> -``` - -Visit [the experimental Fonts documentation](https://docs.astro.build/en/reference/experimental-flags/fonts/) for the full API, how to get started, and even how to build your own custom `AstroFontProvider` if we don't yet support your preferred font service. - -For a complete overview, and to give feedback on this experimental API, see the [Fonts RFC](https://github.com/withastro/roadmap/pull/1039) and help shape its future. diff --git a/.changeset/poor-ends-count.md b/.changeset/poor-ends-count.md deleted file mode 100644 index bab54da96..000000000 --- a/.changeset/poor-ends-count.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Updates the [Audit](http://docs.astro.build/en/guides/dev-toolbar/#audit) dev toolbar app to automatically strip `data-astro-source-file` and `data-astro-source-loc` attributes in dev mode. diff --git a/.changeset/puny-masks-laugh.md b/.changeset/puny-masks-laugh.md deleted file mode 100644 index 48ab52d16..000000000 --- a/.changeset/puny-masks-laugh.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Fix routing with base paths when trailingSlash is set to 'never'. This ensures requests to '/base' are correctly matched when the base path is set to '/base', without requiring a trailing slash. diff --git a/.changeset/tricky-adults-jump.md b/.changeset/tricky-adults-jump.md deleted file mode 100644 index 2f2abe6cf..000000000 --- a/.changeset/tricky-adults-jump.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -"astro": patch ---- - -Adds the minimal starter template to the list of `create astro` options - -Good news if you're taking the introductory tutorial in docs, making a minimal reproduction, or just want to start a project with as little to rip out as possible. Astro's `minimal` (empty) template is now back as one of the options when running `create astro@latest` and starting a new project! diff --git a/.changeset/wild-rabbits-arrive.md b/.changeset/wild-rabbits-arrive.md deleted file mode 100644 index f3f1b9761..000000000 --- a/.changeset/wild-rabbits-arrive.md +++ /dev/null @@ -1,40 +0,0 @@ ---- -'astro': minor ---- - -The virtual module `astro:config` introduced behind a flag in [v5.2.0](https://github.com/withastro/astro/blob/main/packages/astro/CHANGELOG.md#520) is no longer experimental and is available for general use. - -This virtual module exposes two sub-paths for type-safe, controlled access to your configuration: - -- `astro:config/client`: exposes config information that is safe to expose to the client. -- `astro:config/server`: exposes additional information that is safe to expose to the server, such as file and directory paths. - -Access these in any file inside your project to import and use select values from your Astro config: - - ```js - // src/utils.js - import { trailingSlash } from 'astro:config/client'; - - function addForwardSlash(path) { - if (trailingSlash === 'always') { - return path.endsWith('/') ? path : path + '/'; - } else { - return path; - } - } - ``` - -If you were previously using this feature, please remove the experimental flag from your Astro config: - -```diff -// astro.config.mjs -export default defineConfig({ -- experimental: { -- serializeConfig: true -- } -}) -``` - -If you have been waiting for feature stabilization before using configuration imports, you can now do so. - -Please see [the `astro:config` reference](https://docs.astro.build/en/my-feature/) for more about this feature. diff --git a/.changeset/young-kids-turn.md b/.changeset/young-kids-turn.md deleted file mode 100644 index bc3cd0964..000000000 --- a/.changeset/young-kids-turn.md +++ /dev/null @@ -1,36 +0,0 @@ ---- -'@astrojs/markdoc': minor -'astro': minor ---- - -The SVG import feature introduced behind a flag in [v5.0.0](https://github.com/withastro/astro/blob/main/packages/astro/CHANGELOG.md#500) is no longer experimental and is available for general use. - -This feature allows you to import SVG files directly into your Astro project as components and inline them into your HTML. - -To use this feature, import an SVG file in your Astro project, passing any common SVG attributes to the imported component. - -```astro ---- -import Logo from './path/to/svg/file.svg'; ---- -<Logo <Logo width={64} height={64} fill="currentColor" /> -``` - -If you have been waiting for stabilization before using the SVG Components feature, you can now do so. - -If you were previously using this feature, please remove the experimental flag from your Astro config: - -```diff -import { defineConfig } from 'astro' - -export default defineConfig({ -- experimental: { -- svg: true, -- } -}) -``` - -Additionally, a few features that were available during the experimental stage were removed in a previous release. Please see [the v5.6.0 changelog](https://github.com/withastro/astro/blob/main/packages/astro/CHANGELOG.md#560) for details if you have not yet already updated your project code for the experimental feature accordingly. - - -Please see the [SVG Components guide in docs](https://docs.astro.build/en/guides/images/#svg-components) for more about this feature. diff --git a/examples/basics/package.json b/examples/basics/package.json index 06502e152..21e8d3e30 100644 --- a/examples/basics/package.json +++ b/examples/basics/package.json @@ -10,6 +10,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^5.6.2" + "astro": "^5.7.0" } } diff --git a/examples/blog/package.json b/examples/blog/package.json index 62e7554f7..b57ab6c4a 100644 --- a/examples/blog/package.json +++ b/examples/blog/package.json @@ -13,6 +13,6 @@ "@astrojs/mdx": "^4.2.4", "@astrojs/rss": "^4.0.11", "@astrojs/sitemap": "^3.3.0", - "astro": "^5.6.2" + "astro": "^5.7.0" } } diff --git a/examples/component/package.json b/examples/component/package.json index 283642051..fa1504200 100644 --- a/examples/component/package.json +++ b/examples/component/package.json @@ -15,7 +15,7 @@ ], "scripts": {}, "devDependencies": { - "astro": "^5.6.2" + "astro": "^5.7.0" }, "peerDependencies": { "astro": "^4.0.0 || ^5.0.0" diff --git a/examples/container-with-vitest/package.json b/examples/container-with-vitest/package.json index f8b97a7a9..eb4870535 100644 --- a/examples/container-with-vitest/package.json +++ b/examples/container-with-vitest/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/react": "^4.2.4", - "astro": "^5.6.2", + "astro": "^5.7.0", "react": "^18.3.1", "react-dom": "^18.3.1", "vitest": "^3.1.1" diff --git a/examples/framework-alpine/package.json b/examples/framework-alpine/package.json index 048838d0b..c60f17a35 100644 --- a/examples/framework-alpine/package.json +++ b/examples/framework-alpine/package.json @@ -13,6 +13,6 @@ "@astrojs/alpinejs": "^0.4.6", "@types/alpinejs": "^3.13.11", "alpinejs": "^3.14.9", - "astro": "^5.6.2" + "astro": "^5.7.0" } } diff --git a/examples/framework-multiple/package.json b/examples/framework-multiple/package.json index 81f7a4e7c..f940ccdcd 100644 --- a/examples/framework-multiple/package.json +++ b/examples/framework-multiple/package.json @@ -17,7 +17,7 @@ "@astrojs/vue": "^5.0.10", "@types/react": "^18.3.20", "@types/react-dom": "^18.3.6", - "astro": "^5.6.2", + "astro": "^5.7.0", "preact": "^10.26.5", "react": "^18.3.1", "react-dom": "^18.3.1", diff --git a/examples/framework-preact/package.json b/examples/framework-preact/package.json index 66cf2adbe..b2876250c 100644 --- a/examples/framework-preact/package.json +++ b/examples/framework-preact/package.json @@ -12,7 +12,7 @@ "dependencies": { "@astrojs/preact": "^4.0.9", "@preact/signals": "^2.0.3", - "astro": "^5.6.2", + "astro": "^5.7.0", "preact": "^10.26.5" } } diff --git a/examples/framework-react/package.json b/examples/framework-react/package.json index 7dafc6ba0..1ca7c0337 100644 --- a/examples/framework-react/package.json +++ b/examples/framework-react/package.json @@ -13,7 +13,7 @@ "@astrojs/react": "^4.2.4", "@types/react": "^18.3.20", "@types/react-dom": "^18.3.6", - "astro": "^5.6.2", + "astro": "^5.7.0", "react": "^18.3.1", "react-dom": "^18.3.1" } diff --git a/examples/framework-solid/package.json b/examples/framework-solid/package.json index 9694fd5dc..8da42ebb4 100644 --- a/examples/framework-solid/package.json +++ b/examples/framework-solid/package.json @@ -11,7 +11,7 @@ }, "dependencies": { "@astrojs/solid-js": "^5.0.8", - "astro": "^5.6.2", + "astro": "^5.7.0", "solid-js": "^1.9.5" } } diff --git a/examples/framework-svelte/package.json b/examples/framework-svelte/package.json index e20fad929..bd462967e 100644 --- a/examples/framework-svelte/package.json +++ b/examples/framework-svelte/package.json @@ -11,7 +11,7 @@ }, "dependencies": { "@astrojs/svelte": "^7.0.10", - "astro": "^5.6.2", + "astro": "^5.7.0", "svelte": "^5.25.7" } } diff --git a/examples/framework-vue/package.json b/examples/framework-vue/package.json index 3ef65f479..a8f0513ea 100644 --- a/examples/framework-vue/package.json +++ b/examples/framework-vue/package.json @@ -11,7 +11,7 @@ }, "dependencies": { "@astrojs/vue": "^5.0.10", - "astro": "^5.6.2", + "astro": "^5.7.0", "vue": "^3.5.13" } } diff --git a/examples/hackernews/package.json b/examples/hackernews/package.json index 250b4c771..aac006273 100644 --- a/examples/hackernews/package.json +++ b/examples/hackernews/package.json @@ -10,7 +10,7 @@ "astro": "astro" }, "dependencies": { - "@astrojs/node": "^9.1.3", - "astro": "^5.6.2" + "@astrojs/node": "^9.2.0", + "astro": "^5.7.0" } } diff --git a/examples/integration/package.json b/examples/integration/package.json index 64a78eaf6..7a269d038 100644 --- a/examples/integration/package.json +++ b/examples/integration/package.json @@ -15,7 +15,7 @@ ], "scripts": {}, "devDependencies": { - "astro": "^5.6.2" + "astro": "^5.7.0" }, "peerDependencies": { "astro": "^4.0.0" diff --git a/examples/minimal/package.json b/examples/minimal/package.json index f00c8bf04..df816b83e 100644 --- a/examples/minimal/package.json +++ b/examples/minimal/package.json @@ -10,6 +10,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^5.6.2" + "astro": "^5.7.0" } } diff --git a/examples/portfolio/package.json b/examples/portfolio/package.json index bec99f1f8..b6b081cb0 100644 --- a/examples/portfolio/package.json +++ b/examples/portfolio/package.json @@ -10,6 +10,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^5.6.2" + "astro": "^5.7.0" } } diff --git a/examples/ssr/package.json b/examples/ssr/package.json index 8432ee97e..8830c5f2f 100644 --- a/examples/ssr/package.json +++ b/examples/ssr/package.json @@ -11,9 +11,9 @@ "server": "node dist/server/entry.mjs" }, "dependencies": { - "@astrojs/node": "^9.1.3", + "@astrojs/node": "^9.2.0", "@astrojs/svelte": "^7.0.10", - "astro": "^5.6.2", + "astro": "^5.7.0", "svelte": "^5.25.7" } } diff --git a/examples/starlog/package.json b/examples/starlog/package.json index b4bafb339..4e886cb1b 100644 --- a/examples/starlog/package.json +++ b/examples/starlog/package.json @@ -9,7 +9,7 @@ "astro": "astro" }, "dependencies": { - "astro": "^5.6.2", + "astro": "^5.7.0", "sass": "^1.86.3", "sharp": "^0.33.3" } diff --git a/examples/toolbar-app/package.json b/examples/toolbar-app/package.json index 917fde104..a4d2517d3 100644 --- a/examples/toolbar-app/package.json +++ b/examples/toolbar-app/package.json @@ -16,6 +16,6 @@ }, "devDependencies": { "@types/node": "^18.17.8", - "astro": "^5.6.2" + "astro": "^5.7.0" } } diff --git a/examples/with-markdoc/package.json b/examples/with-markdoc/package.json index ac79cde9a..64a47aada 100644 --- a/examples/with-markdoc/package.json +++ b/examples/with-markdoc/package.json @@ -10,7 +10,7 @@ "astro": "astro" }, "dependencies": { - "@astrojs/markdoc": "^0.13.4", - "astro": "^5.6.2" + "@astrojs/markdoc": "^0.14.0", + "astro": "^5.7.0" } } diff --git a/examples/with-mdx/package.json b/examples/with-mdx/package.json index c70e37883..6f29fa981 100644 --- a/examples/with-mdx/package.json +++ b/examples/with-mdx/package.json @@ -12,7 +12,7 @@ "dependencies": { "@astrojs/mdx": "^4.2.4", "@astrojs/preact": "^4.0.9", - "astro": "^5.6.2", + "astro": "^5.7.0", "preact": "^10.26.5" } } diff --git a/examples/with-nanostores/package.json b/examples/with-nanostores/package.json index 47fbf9352..f916a33f4 100644 --- a/examples/with-nanostores/package.json +++ b/examples/with-nanostores/package.json @@ -12,7 +12,7 @@ "dependencies": { "@astrojs/preact": "^4.0.9", "@nanostores/preact": "^0.5.2", - "astro": "^5.6.2", + "astro": "^5.7.0", "nanostores": "^0.11.4", "preact": "^10.26.5" } diff --git a/examples/with-tailwindcss/package.json b/examples/with-tailwindcss/package.json index a25deb686..7c3553b8e 100644 --- a/examples/with-tailwindcss/package.json +++ b/examples/with-tailwindcss/package.json @@ -13,7 +13,7 @@ "@astrojs/mdx": "^4.2.4", "@tailwindcss/vite": "^4.1.3", "@types/canvas-confetti": "^1.9.0", - "astro": "^5.6.2", + "astro": "^5.7.0", "canvas-confetti": "^1.9.3", "tailwindcss": "^4.1.3" } diff --git a/examples/with-vitest/package.json b/examples/with-vitest/package.json index ab8f2d833..0aa6c92a0 100644 --- a/examples/with-vitest/package.json +++ b/examples/with-vitest/package.json @@ -11,7 +11,7 @@ "test": "vitest" }, "dependencies": { - "astro": "^5.6.2", + "astro": "^5.7.0", "vitest": "^3.1.1" } } diff --git a/packages/astro/CHANGELOG.md b/packages/astro/CHANGELOG.md index 671eff3a8..1a783091b 100644 --- a/packages/astro/CHANGELOG.md +++ b/packages/astro/CHANGELOG.md @@ -1,5 +1,210 @@ # astro +## 5.7.0 + +### Minor Changes + +- [#13527](https://github.com/withastro/astro/pull/13527) [`2fd6a6b`](https://github.com/withastro/astro/commit/2fd6a6b7aa51a4713af7fac37d5dfd824543c1bc) Thanks [@ascorbic](https://github.com/ascorbic)! - The experimental session API introduced in Astro 5.1 is now stable and ready for production use. + + Sessions are used to store user state between requests for [on-demand rendered pages](https://astro.build/en/guides/on-demand-rendering/). You can use them to store user data, such as authentication tokens, shopping cart contents, or any other data that needs to persist across requests: + + ```astro + --- + export const prerender = false; // Not needed with 'server' output + const cart = await Astro.session.get('cart'); + --- + + <a href="/checkout">🛒 {cart?.length ?? 0} items</a> + ``` + + ## Configuring session storage + + Sessions require a storage driver to store the data. The Node, Cloudflare and Netlify adapters automatically configure a default driver for you, but other adapters currently require you to specify a custom storage driver in your configuration. + + If you are using an adapter that doesn't have a default driver, or if you want to choose a different driver, you can configure it using the `session` configuration option: + + ```js + import { defineConfig } from 'astro/config'; + import vercel from '@astrojs/vercel'; + + export default defineConfig({ + adapter: vercel(), + session: { + driver: 'upstash', + }, + }); + ``` + + ## Using sessions + + Sessions are available in on-demand rendered pages, API endpoints, actions and middleware. + + In pages and components, you can access the session using `Astro.session`: + + ```astro + --- + const cart = await Astro.session.get('cart'); + --- + + <a href="/checkout">🛒 {cart?.length ?? 0} items</a> + ``` + + In endpoints, actions, and middleware, you can access the session using `context.session`: + + ```js + export async function GET(context) { + const cart = await context.session.get('cart'); + return Response.json({ cart }); + } + ``` + + If you attempt to access the session when there is no storage driver configured, or in a prerendered page, the session object will be `undefined` and an error will be logged in the console: + + ```astro + --- + export const prerender = true; + const cart = await Astro.session?.get('cart'); // Logs an error. Astro.session is undefined + --- + ``` + + ## Upgrading from Experimental to Stable + + If you were previously using the experimental API, please remove the `experimental.session` flag from your configuration: + + ```diff + import { defineConfig } from 'astro/config'; + import node from '@astrojs/node'; + + export default defineConfig({ + adapter: node({ + mode: "standalone", + }), + - experimental: { + - session: true, + - }, + }); + ``` + + See [the sessions guide](https://docs.astro.build/en/guides/sessions/) for more information. + +- [#12775](https://github.com/withastro/astro/pull/12775) [`b1fe521`](https://github.com/withastro/astro/commit/b1fe521e2c45172b786594c50c0ca595105a6d68) Thanks [@florian-lefebvre](https://github.com/florian-lefebvre)! - Adds a new, experimental Fonts API to provide first-party support for fonts in Astro. + + This experimental feature allows you to use fonts from both your file system and several built-in supported providers (e.g. Google, Fontsource, Bunny) through a unified API. Keep your site performant thanks to sensible defaults and automatic optimizations including fallback font generation. + + To enable this feature, configure an `experimental.fonts` object with one or more fonts: + + ```js title="astro.config.mjs" + import { defineConfig, fontProviders } from "astro/config" + + export default defineConfig({ + experimental: { + fonts: [{ + provider: fontProviders.google(), + ` name: "Roboto", + cssVariable: "--font-roboto", + }] + } + }) + ``` + + Then, add a `<Font />` component and site-wide styling in your `<head>`: + + ```astro title="src/components/Head.astro" + --- + import { Font } from 'astro:assets'; + --- + + <Font cssVariable="--font-roboto" preload /> + <style> + body { + font-family: var(--font-roboto); + } + </style> + ``` + + Visit [the experimental Fonts documentation](https://docs.astro.build/en/reference/experimental-flags/fonts/) for the full API, how to get started, and even how to build your own custom `AstroFontProvider` if we don't yet support your preferred font service. + + For a complete overview, and to give feedback on this experimental API, see the [Fonts RFC](https://github.com/withastro/roadmap/pull/1039) and help shape its future. + +- [#13560](https://github.com/withastro/astro/pull/13560) [`df3fd54`](https://github.com/withastro/astro/commit/df3fd5434514b68cf1fe499a2e28bc1215bd253d) Thanks [@ematipico](https://github.com/ematipico)! - The virtual module `astro:config` introduced behind a flag in [v5.2.0](https://github.com/withastro/astro/blob/main/packages/astro/CHANGELOG.md#520) is no longer experimental and is available for general use. + + This virtual module exposes two sub-paths for type-safe, controlled access to your configuration: + + - `astro:config/client`: exposes config information that is safe to expose to the client. + - `astro:config/server`: exposes additional information that is safe to expose to the server, such as file and directory paths. + + Access these in any file inside your project to import and use select values from your Astro config: + + ```js + // src/utils.js + import { trailingSlash } from 'astro:config/client'; + + function addForwardSlash(path) { + if (trailingSlash === 'always') { + return path.endsWith('/') ? path : path + '/'; + } else { + return path; + } + } + ``` + + If you were previously using this feature, please remove the experimental flag from your Astro config: + + ```diff + // astro.config.mjs + export default defineConfig({ + - experimental: { + - serializeConfig: true + - } + }) + ``` + + If you have been waiting for feature stabilization before using configuration imports, you can now do so. + + Please see [the `astro:config` reference](https://docs.astro.build/en/my-feature/) for more about this feature. + +- [#13578](https://github.com/withastro/astro/pull/13578) [`406501a`](https://github.com/withastro/astro/commit/406501aeb7f314ae5c31f31a373c270e3b9ec715) Thanks [@stramel](https://github.com/stramel)! - The SVG import feature introduced behind a flag in [v5.0.0](https://github.com/withastro/astro/blob/main/packages/astro/CHANGELOG.md#500) is no longer experimental and is available for general use. + + This feature allows you to import SVG files directly into your Astro project as components and inline them into your HTML. + + To use this feature, import an SVG file in your Astro project, passing any common SVG attributes to the imported component. + + ```astro + --- + import Logo from './path/to/svg/file.svg'; + --- + + <Logo <Logo width={64} height={64} fill="currentColor" /> + ``` + + If you have been waiting for stabilization before using the SVG Components feature, you can now do so. + + If you were previously using this feature, please remove the experimental flag from your Astro config: + + ```diff + import { defineConfig } from 'astro' + + export default defineConfig({ + - experimental: { + - svg: true, + - } + }) + ``` + + Additionally, a few features that were available during the experimental stage were removed in a previous release. Please see [the v5.6.0 changelog](https://github.com/withastro/astro/blob/main/packages/astro/CHANGELOG.md#560) for details if you have not yet already updated your project code for the experimental feature accordingly. + + Please see the [SVG Components guide in docs](https://docs.astro.build/en/guides/images/#svg-components) for more about this feature. + +### Patch Changes + +- [#13602](https://github.com/withastro/astro/pull/13602) [`3213450`](https://github.com/withastro/astro/commit/3213450bda5b21527a03d292a5f222f35293f9bb) Thanks [@natemoo-re](https://github.com/natemoo-re)! - Updates the [Audit](http://docs.astro.build/en/guides/dev-toolbar/#audit) dev toolbar app to automatically strip `data-astro-source-file` and `data-astro-source-loc` attributes in dev mode. + +- [#13598](https://github.com/withastro/astro/pull/13598) [`f5de51e`](https://github.com/withastro/astro/commit/f5de51e94755cdbeaa19667309b5f1aa0c416bd4) Thanks [@dreyfus92](https://github.com/dreyfus92)! - Fix routing with base paths when trailingSlash is set to 'never'. This ensures requests to '/base' are correctly matched when the base path is set to '/base', without requiring a trailing slash. + +- [#13603](https://github.com/withastro/astro/pull/13603) [`d038030`](https://github.com/withastro/astro/commit/d038030770b294e811beb99c9478fbe4b4cbb968) Thanks [@sarah11918](https://github.com/sarah11918)! - Adds the minimal starter template to the list of `create astro` options + + Good news if you're taking the introductory tutorial in docs, making a minimal reproduction, or just want to start a project with as little to rip out as possible. Astro's `minimal` (empty) template is now back as one of the options when running `create astro@latest` and starting a new project! + ## 5.6.2 ### Patch Changes diff --git a/packages/astro/package.json b/packages/astro/package.json index cdbe7b93b..7586e3699 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -1,6 +1,6 @@ { "name": "astro", - "version": "5.6.2", + "version": "5.7.0", "description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.", "type": "module", "author": "withastro", diff --git a/packages/integrations/cloudflare/CHANGELOG.md b/packages/integrations/cloudflare/CHANGELOG.md index f4bfcaf9e..153e65388 100644 --- a/packages/integrations/cloudflare/CHANGELOG.md +++ b/packages/integrations/cloudflare/CHANGELOG.md @@ -1,5 +1,97 @@ # @astrojs/cloudflare +## 12.5.0 + +### Minor Changes + +- [#13527](https://github.com/withastro/astro/pull/13527) [`2fd6a6b`](https://github.com/withastro/astro/commit/2fd6a6b7aa51a4713af7fac37d5dfd824543c1bc) Thanks [@ascorbic](https://github.com/ascorbic)! - The experimental session API introduced in Astro 5.1 is now stable and ready for production use. + + Sessions are used to store user state between requests for [on-demand rendered pages](https://astro.build/en/guides/on-demand-rendering/). You can use them to store user data, such as authentication tokens, shopping cart contents, or any other data that needs to persist across requests: + + ```astro + --- + export const prerender = false; // Not needed with 'server' output + const cart = await Astro.session.get('cart'); + --- + + <a href="/checkout">🛒 {cart?.length ?? 0} items</a> + ``` + + ## Configuring session storage + + Sessions require a storage driver to store the data. The Node, Cloudflare and Netlify adapters automatically configure a default driver for you, but other adapters currently require you to specify a custom storage driver in your configuration. + + If you are using an adapter that doesn't have a default driver, or if you want to choose a different driver, you can configure it using the `session` configuration option: + + ```js + import { defineConfig } from 'astro/config'; + import vercel from '@astrojs/vercel'; + + export default defineConfig({ + adapter: vercel(), + session: { + driver: 'upstash', + }, + }); + ``` + + ## Using sessions + + Sessions are available in on-demand rendered pages, API endpoints, actions and middleware. + + In pages and components, you can access the session using `Astro.session`: + + ```astro + --- + const cart = await Astro.session.get('cart'); + --- + + <a href="/checkout">🛒 {cart?.length ?? 0} items</a> + ``` + + In endpoints, actions, and middleware, you can access the session using `context.session`: + + ```js + export async function GET(context) { + const cart = await context.session.get('cart'); + return Response.json({ cart }); + } + ``` + + If you attempt to access the session when there is no storage driver configured, or in a prerendered page, the session object will be `undefined` and an error will be logged in the console: + + ```astro + --- + export const prerender = true; + const cart = await Astro.session?.get('cart'); // Logs an error. Astro.session is undefined + --- + ``` + + ## Upgrading from Experimental to Stable + + If you were previously using the experimental API, please remove the `experimental.session` flag from your configuration: + + ```diff + import { defineConfig } from 'astro/config'; + import node from '@astrojs/node'; + + export default defineConfig({ + adapter: node({ + mode: "standalone", + }), + - experimental: { + - session: true, + - }, + }); + ``` + + See [the sessions guide](https://docs.astro.build/en/guides/sessions/) for more information. + +### Patch Changes + +- Updated dependencies []: + - @astrojs/underscore-redirects@0.6.0 + ## 12.4.1 ### Patch Changes diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index 3f5c6350f..650bf801a 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/cloudflare", "description": "Deploy your site to Cloudflare Workers/Pages", - "version": "12.4.1", + "version": "12.5.0", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", diff --git a/packages/integrations/markdoc/CHANGELOG.md b/packages/integrations/markdoc/CHANGELOG.md index b60c3c796..a699cce73 100644 --- a/packages/integrations/markdoc/CHANGELOG.md +++ b/packages/integrations/markdoc/CHANGELOG.md @@ -1,5 +1,41 @@ # @astrojs/markdoc +## 0.14.0 + +### Minor Changes + +- [#13578](https://github.com/withastro/astro/pull/13578) [`406501a`](https://github.com/withastro/astro/commit/406501aeb7f314ae5c31f31a373c270e3b9ec715) Thanks [@stramel](https://github.com/stramel)! - The SVG import feature introduced behind a flag in [v5.0.0](https://github.com/withastro/astro/blob/main/packages/astro/CHANGELOG.md#500) is no longer experimental and is available for general use. + + This feature allows you to import SVG files directly into your Astro project as components and inline them into your HTML. + + To use this feature, import an SVG file in your Astro project, passing any common SVG attributes to the imported component. + + ```astro + --- + import Logo from './path/to/svg/file.svg'; + --- + + <Logo <Logo width={64} height={64} fill="currentColor" /> + ``` + + If you have been waiting for stabilization before using the SVG Components feature, you can now do so. + + If you were previously using this feature, please remove the experimental flag from your Astro config: + + ```diff + import { defineConfig } from 'astro' + + export default defineConfig({ + - experimental: { + - svg: true, + - } + }) + ``` + + Additionally, a few features that were available during the experimental stage were removed in a previous release. Please see [the v5.6.0 changelog](https://github.com/withastro/astro/blob/main/packages/astro/CHANGELOG.md#560) for details if you have not yet already updated your project code for the experimental feature accordingly. + + Please see the [SVG Components guide in docs](https://docs.astro.build/en/guides/images/#svg-components) for more about this feature. + ## 0.13.4 ### Patch Changes diff --git a/packages/integrations/markdoc/package.json b/packages/integrations/markdoc/package.json index 6f07eaf98..9566b4c41 100644 --- a/packages/integrations/markdoc/package.json +++ b/packages/integrations/markdoc/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/markdoc", "description": "Add support for Markdoc in your Astro site", - "version": "0.13.4", + "version": "0.14.0", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", diff --git a/packages/integrations/netlify/CHANGELOG.md b/packages/integrations/netlify/CHANGELOG.md index faadc2dff..635d1610a 100644 --- a/packages/integrations/netlify/CHANGELOG.md +++ b/packages/integrations/netlify/CHANGELOG.md @@ -1,5 +1,97 @@ # @astrojs/netlify +## 6.3.0 + +### Minor Changes + +- [#13527](https://github.com/withastro/astro/pull/13527) [`2fd6a6b`](https://github.com/withastro/astro/commit/2fd6a6b7aa51a4713af7fac37d5dfd824543c1bc) Thanks [@ascorbic](https://github.com/ascorbic)! - The experimental session API introduced in Astro 5.1 is now stable and ready for production use. + + Sessions are used to store user state between requests for [on-demand rendered pages](https://astro.build/en/guides/on-demand-rendering/). You can use them to store user data, such as authentication tokens, shopping cart contents, or any other data that needs to persist across requests: + + ```astro + --- + export const prerender = false; // Not needed with 'server' output + const cart = await Astro.session.get('cart'); + --- + + <a href="/checkout">🛒 {cart?.length ?? 0} items</a> + ``` + + ## Configuring session storage + + Sessions require a storage driver to store the data. The Node, Cloudflare and Netlify adapters automatically configure a default driver for you, but other adapters currently require you to specify a custom storage driver in your configuration. + + If you are using an adapter that doesn't have a default driver, or if you want to choose a different driver, you can configure it using the `session` configuration option: + + ```js + import { defineConfig } from 'astro/config'; + import vercel from '@astrojs/vercel'; + + export default defineConfig({ + adapter: vercel(), + session: { + driver: 'upstash', + }, + }); + ``` + + ## Using sessions + + Sessions are available in on-demand rendered pages, API endpoints, actions and middleware. + + In pages and components, you can access the session using `Astro.session`: + + ```astro + --- + const cart = await Astro.session.get('cart'); + --- + + <a href="/checkout">🛒 {cart?.length ?? 0} items</a> + ``` + + In endpoints, actions, and middleware, you can access the session using `context.session`: + + ```js + export async function GET(context) { + const cart = await context.session.get('cart'); + return Response.json({ cart }); + } + ``` + + If you attempt to access the session when there is no storage driver configured, or in a prerendered page, the session object will be `undefined` and an error will be logged in the console: + + ```astro + --- + export const prerender = true; + const cart = await Astro.session?.get('cart'); // Logs an error. Astro.session is undefined + --- + ``` + + ## Upgrading from Experimental to Stable + + If you were previously using the experimental API, please remove the `experimental.session` flag from your configuration: + + ```diff + import { defineConfig } from 'astro/config'; + import node from '@astrojs/node'; + + export default defineConfig({ + adapter: node({ + mode: "standalone", + }), + - experimental: { + - session: true, + - }, + }); + ``` + + See [the sessions guide](https://docs.astro.build/en/guides/sessions/) for more information. + +### Patch Changes + +- Updated dependencies []: + - @astrojs/underscore-redirects@0.6.0 + ## 6.2.6 ### Patch Changes diff --git a/packages/integrations/netlify/package.json b/packages/integrations/netlify/package.json index eec86017a..4a0860647 100644 --- a/packages/integrations/netlify/package.json +++ b/packages/integrations/netlify/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/netlify", "description": "Deploy your site to Netlify", - "version": "6.2.6", + "version": "6.3.0", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", diff --git a/packages/integrations/node/CHANGELOG.md b/packages/integrations/node/CHANGELOG.md index 5b86cca17..b4df5833b 100644 --- a/packages/integrations/node/CHANGELOG.md +++ b/packages/integrations/node/CHANGELOG.md @@ -1,5 +1,92 @@ # @astrojs/node +## 9.2.0 + +### Minor Changes + +- [#13527](https://github.com/withastro/astro/pull/13527) [`2fd6a6b`](https://github.com/withastro/astro/commit/2fd6a6b7aa51a4713af7fac37d5dfd824543c1bc) Thanks [@ascorbic](https://github.com/ascorbic)! - The experimental session API introduced in Astro 5.1 is now stable and ready for production use. + + Sessions are used to store user state between requests for [on-demand rendered pages](https://astro.build/en/guides/on-demand-rendering/). You can use them to store user data, such as authentication tokens, shopping cart contents, or any other data that needs to persist across requests: + + ```astro + --- + export const prerender = false; // Not needed with 'server' output + const cart = await Astro.session.get('cart'); + --- + + <a href="/checkout">🛒 {cart?.length ?? 0} items</a> + ``` + + ## Configuring session storage + + Sessions require a storage driver to store the data. The Node, Cloudflare and Netlify adapters automatically configure a default driver for you, but other adapters currently require you to specify a custom storage driver in your configuration. + + If you are using an adapter that doesn't have a default driver, or if you want to choose a different driver, you can configure it using the `session` configuration option: + + ```js + import { defineConfig } from 'astro/config'; + import vercel from '@astrojs/vercel'; + + export default defineConfig({ + adapter: vercel(), + session: { + driver: 'upstash', + }, + }); + ``` + + ## Using sessions + + Sessions are available in on-demand rendered pages, API endpoints, actions and middleware. + + In pages and components, you can access the session using `Astro.session`: + + ```astro + --- + const cart = await Astro.session.get('cart'); + --- + + <a href="/checkout">🛒 {cart?.length ?? 0} items</a> + ``` + + In endpoints, actions, and middleware, you can access the session using `context.session`: + + ```js + export async function GET(context) { + const cart = await context.session.get('cart'); + return Response.json({ cart }); + } + ``` + + If you attempt to access the session when there is no storage driver configured, or in a prerendered page, the session object will be `undefined` and an error will be logged in the console: + + ```astro + --- + export const prerender = true; + const cart = await Astro.session?.get('cart'); // Logs an error. Astro.session is undefined + --- + ``` + + ## Upgrading from Experimental to Stable + + If you were previously using the experimental API, please remove the `experimental.session` flag from your configuration: + + ```diff + import { defineConfig } from 'astro/config'; + import node from '@astrojs/node'; + + export default defineConfig({ + adapter: node({ + mode: "standalone", + }), + - experimental: { + - session: true, + - }, + }); + ``` + + See [the sessions guide](https://docs.astro.build/en/guides/sessions/) for more information. + ## 9.1.3 ### Patch Changes diff --git a/packages/integrations/node/package.json b/packages/integrations/node/package.json index 62530c276..f928d52a8 100644 --- a/packages/integrations/node/package.json +++ b/packages/integrations/node/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/node", "description": "Deploy your site to a Node.js server", - "version": "9.1.3", + "version": "9.2.0", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1eca4cdfe..4ea93a9fb 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -147,7 +147,7 @@ importers: examples/basics: dependencies: astro: - specifier: ^5.6.2 + specifier: ^5.7.0 version: link:../../packages/astro examples/blog: @@ -162,13 +162,13 @@ importers: specifier: ^3.3.0 version: link:../../packages/integrations/sitemap astro: - specifier: ^5.6.2 + specifier: ^5.7.0 version: link:../../packages/astro examples/component: devDependencies: astro: - specifier: ^5.6.2 + specifier: ^5.7.0 version: link:../../packages/astro examples/container-with-vitest: @@ -177,7 +177,7 @@ importers: specifier: ^4.2.4 version: link:../../packages/integrations/react astro: - specifier: ^5.6.2 + specifier: ^5.7.0 version: link:../../packages/astro react: specifier: ^18.3.1 @@ -208,7 +208,7 @@ importers: specifier: ^3.14.9 version: 3.14.9 astro: - specifier: ^5.6.2 + specifier: ^5.7.0 version: link:../../packages/astro examples/framework-multiple: @@ -235,7 +235,7 @@ importers: specifier: ^18.3.6 version: 18.3.6(@types/react@18.3.20) astro: - specifier: ^5.6.2 + specifier: ^5.7.0 version: link:../../packages/astro preact: specifier: ^10.26.5 @@ -265,7 +265,7 @@ importers: specifier: ^2.0.3 version: 2.0.3(preact@10.26.5) astro: - specifier: ^5.6.2 + specifier: ^5.7.0 version: link:../../packages/astro preact: specifier: ^10.26.5 @@ -283,7 +283,7 @@ importers: specifier: ^18.3.6 version: 18.3.6(@types/react@18.3.20) astro: - specifier: ^5.6.2 + specifier: ^5.7.0 version: link:../../packages/astro react: specifier: ^18.3.1 @@ -298,7 +298,7 @@ importers: specifier: ^5.0.8 version: link:../../packages/integrations/solid astro: - specifier: ^5.6.2 + specifier: ^5.7.0 version: link:../../packages/astro solid-js: specifier: ^1.9.5 @@ -310,7 +310,7 @@ importers: specifier: ^7.0.10 version: link:../../packages/integrations/svelte astro: - specifier: ^5.6.2 + specifier: ^5.7.0 version: link:../../packages/astro svelte: specifier: ^5.25.7 @@ -322,7 +322,7 @@ importers: specifier: ^5.0.10 version: link:../../packages/integrations/vue astro: - specifier: ^5.6.2 + specifier: ^5.7.0 version: link:../../packages/astro vue: specifier: ^3.5.13 @@ -331,40 +331,40 @@ importers: examples/hackernews: dependencies: '@astrojs/node': - specifier: ^9.1.3 + specifier: ^9.2.0 version: link:../../packages/integrations/node astro: - specifier: ^5.6.2 + specifier: ^5.7.0 version: link:../../packages/astro examples/integration: devDependencies: astro: - specifier: ^5.6.2 + specifier: ^5.7.0 version: link:../../packages/astro examples/minimal: dependencies: astro: - specifier: ^5.6.2 + specifier: ^5.7.0 version: link:../../packages/astro examples/portfolio: dependencies: astro: - specifier: ^5.6.2 + specifier: ^5.7.0 version: link:../../packages/astro examples/ssr: dependencies: '@astrojs/node': - specifier: ^9.1.3 + specifier: ^9.2.0 version: link:../../packages/integrations/node '@astrojs/svelte': specifier: ^7.0.10 version: link:../../packages/integrations/svelte astro: - specifier: ^5.6.2 + specifier: ^5.7.0 version: link:../../packages/astro svelte: specifier: ^5.25.7 @@ -373,7 +373,7 @@ importers: examples/starlog: dependencies: astro: - specifier: ^5.6.2 + specifier: ^5.7.0 version: link:../../packages/astro sass: specifier: ^1.86.3 @@ -388,16 +388,16 @@ importers: specifier: ^18.17.8 version: 18.19.50 astro: - specifier: ^5.6.2 + specifier: ^5.7.0 version: link:../../packages/astro examples/with-markdoc: dependencies: '@astrojs/markdoc': - specifier: ^0.13.4 + specifier: ^0.14.0 version: link:../../packages/integrations/markdoc astro: - specifier: ^5.6.2 + specifier: ^5.7.0 version: link:../../packages/astro examples/with-mdx: @@ -409,7 +409,7 @@ importers: specifier: ^4.0.9 version: link:../../packages/integrations/preact astro: - specifier: ^5.6.2 + specifier: ^5.7.0 version: link:../../packages/astro preact: specifier: ^10.26.5 @@ -424,7 +424,7 @@ importers: specifier: ^0.5.2 version: 0.5.2(nanostores@0.11.4)(preact@10.26.5) astro: - specifier: ^5.6.2 + specifier: ^5.7.0 version: link:../../packages/astro nanostores: specifier: ^0.11.4 @@ -445,7 +445,7 @@ importers: specifier: ^1.9.0 version: 1.9.0 astro: - specifier: ^5.6.2 + specifier: ^5.7.0 version: link:../../packages/astro canvas-confetti: specifier: ^1.9.3 @@ -457,7 +457,7 @@ importers: examples/with-vitest: dependencies: astro: - specifier: ^5.6.2 + specifier: ^5.7.0 version: link:../../packages/astro vitest: specifier: ^3.1.1 |