diff options
52 files changed, 333 insertions, 338 deletions
diff --git a/.changeset/angry-plants-guess.md b/.changeset/angry-plants-guess.md deleted file mode 100644 index 8798ef703..000000000 --- a/.changeset/angry-plants-guess.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Fixes content types sync in dev diff --git a/.changeset/eleven-pens-glow.md b/.changeset/eleven-pens-glow.md deleted file mode 100644 index d031fba49..000000000 --- a/.changeset/eleven-pens-glow.md +++ /dev/null @@ -1,41 +0,0 @@ ---- -'astro': minor ---- - -Deprecates the option for route-generating files to export a dynamic value for `prerender`. Only static values are now supported (e.g. `export const prerender = true` or `= false`). This allows for better treeshaking and bundling configuration in the future. - -Adds a new [`"astro:route:setup"` hook](https://docs.astro.build/en/reference/integrations-reference/#astroroutesetup) to the Integrations API to allow you to dynamically set options for a route at build or request time through an integration, such as enabling [on-demand server rendering](https://docs.astro.build/en/guides/server-side-rendering/#opting-in-to-pre-rendering-in-server-mode). - -To migrate from a dynamic export to the new hook, update or remove any dynamic `prerender` exports from individual routing files: - -```diff -// src/pages/blog/[slug].astro -- export const prerender = import.meta.env.PRERENDER -``` - -Instead, create an integration with the `"astro:route:setup"` hook and update the route's `prerender` option: - -```js -// astro.config.mjs -import { defineConfig } from 'astro/config'; -import { loadEnv } from 'vite'; - -export default defineConfig({ - integrations: [setPrerender()], -}); - -function setPrerender() { - const { PRERENDER } = loadEnv(process.env.NODE_ENV, process.cwd(), ''); - - return { - name: 'set-prerender', - hooks: { - 'astro:route:setup': ({ route }) => { - if (route.component.endsWith('/blog/[slug].astro')) { - route.prerender = PRERENDER; - } - }, - }, - }; -} -``` diff --git a/.changeset/fifty-stingrays-flow.md b/.changeset/fifty-stingrays-flow.md deleted file mode 100644 index 3f4b96b04..000000000 --- a/.changeset/fifty-stingrays-flow.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -'astro': patch -'@astrojs/db': patch ---- - -Refactors internally to use `node:util` `parseArgs` instead of `yargs-parser` diff --git a/.changeset/fresh-fans-study.md b/.changeset/fresh-fans-study.md deleted file mode 100644 index 9a837b1fd..000000000 --- a/.changeset/fresh-fans-study.md +++ /dev/null @@ -1,18 +0,0 @@ ---- -'@astrojs/db': minor ---- - -Changes how type generation works - -The generated `.d.ts` file is now at a new location: - -```diff -- .astro/db-types.d.ts -+ .astro/integrations/astro_db/db.d.ts -``` - -The following line can now be removed from `src/env.d.ts`: - -```diff -- /// <reference path="../.astro/db-types.d.ts" /> -``` diff --git a/.changeset/kind-bees-admire.md b/.changeset/kind-bees-admire.md deleted file mode 100644 index 7aa359f58..000000000 --- a/.changeset/kind-bees-admire.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Fix mixed use of base + trailingSlash in Server Islands diff --git a/.changeset/mean-horses-kiss.md b/.changeset/mean-horses-kiss.md deleted file mode 100644 index 7d211e626..000000000 --- a/.changeset/mean-horses-kiss.md +++ /dev/null @@ -1,35 +0,0 @@ ---- -'astro': minor ---- - -Adds a new [`injectTypes()` utility](https://docs.astro.build/en/reference/integrations-reference/#injecttypes-options) to the Integration API and refactors how type generation works - -Use `injectTypes()` in the `astro:config:done` hook to inject types into your user's project by adding a new a `*.d.ts` file. - -The `filename` property will be used to generate a file at `/.astro/integrations/<normalized_integration_name>/<normalized_filename>.d.ts` and must end with `".d.ts"`. - -The `content` property will create the body of the file, and must be valid TypeScript. - -Additionally, `injectTypes()` returns a URL to the normalized path so you can overwrite its content later on, or manipulate it in any way you want. - -```js -// my-integration/index.js -export default { - name: 'my-integration', - 'astro:config:done': ({ injectTypes }) => { - injectTypes({ - filename: "types.d.ts", - content: "declare module 'virtual:my-integration' {}" - }) - } -}; -``` - -Codegen has been refactored. Although `src/env.d.ts` will continue to work as is, we recommend you update it: - -```diff -- /// <reference types="astro/client" /> -+ /// <reference path="../.astro/types.d.ts" /> -- /// <reference path="../.astro/env.d.ts" /> -- /// <reference path="../.astro/actions.d.ts" /> -```
\ No newline at end of file diff --git a/.changeset/new-boats-flash.md b/.changeset/new-boats-flash.md deleted file mode 100644 index 4ef58bba4..000000000 --- a/.changeset/new-boats-flash.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Fix adapter causing Netlify to break diff --git a/.changeset/odd-buttons-pay.md b/.changeset/odd-buttons-pay.md deleted file mode 100644 index 728068ef2..000000000 --- a/.changeset/odd-buttons-pay.md +++ /dev/null @@ -1,22 +0,0 @@ ---- -"astro": minor ---- - -Adds a new property `meta` to Astro's [built-in `<Code />` component](https://docs.astro.build/en/reference/api-reference/#code-). - -This allows you to provide a value for [Shiki's `meta` attribute](https://shiki.style/guide/transformers#meta) to pass options to transformers. - -The following example passes an option to highlight lines 1 and 3 to Shiki's `tranformerMetaHighlight`: - -```astro ---- -// src/components/Card.astro -import { Code } from "astro:components"; -import { transformerMetaHighlight } from '@shikijs/transformers'; ---- -<Code - code={code} - lang="js" - transformers={[transformerMetaHighlight()]} - meta="{1,3}" /> -``` diff --git a/.changeset/rude-queens-shop.md b/.changeset/rude-queens-shop.md deleted file mode 100644 index 6610b16a5..000000000 --- a/.changeset/rude-queens-shop.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -'create-astro': patch -'@astrojs/upgrade': patch ---- - -Refactors internally to use `node:util` `parseArgs` instead of `arg` - diff --git a/.changeset/serious-pumas-run.md b/.changeset/serious-pumas-run.md deleted file mode 100644 index e6f7c9af1..000000000 --- a/.changeset/serious-pumas-run.md +++ /dev/null @@ -1,21 +0,0 @@ ---- -'astro': minor ---- - -Adds support for Intellisense features (e.g. code completion, quick hints) for your content collection entries in compatible editors under the `experimental.contentIntellisense` flag. - -```js -import { defineConfig } from 'astro'; - -export default defineConfig({ - experimental: { - contentIntellisense: true - } -}) -``` - -When enabled, this feature will generate and add JSON schemas to the `.astro` directory in your project. These files can be used by the Astro language server to provide Intellisense inside content files (`.md`, `.mdx`, `.mdoc`). - -Note that at this time, this also require enabling the `astro.content-intellisense` option in your editor, or passing the `contentIntellisense: true` initialization parameter to the Astro language server for editors using it directly. - -See the [experimental content Intellisense docs](https://docs.astro.build/en/reference/configuration-reference/#experimentalcontentintellisense) for more information updates as this feature develops. diff --git a/.changeset/smooth-chicken-wash.md b/.changeset/smooth-chicken-wash.md deleted file mode 100644 index 3ced01f52..000000000 --- a/.changeset/smooth-chicken-wash.md +++ /dev/null @@ -1,107 +0,0 @@ ---- -'astro': minor ---- - -Adds experimental support for the Content Layer API. - -The new Content Layer API builds upon content collections, taking them beyond local files in `src/content/` and allowing you to fetch content from anywhere, including remote APIs. These new collections work alongside your existing content collections, and you can migrate them to the new API at your own pace. There are significant improvements to performance with large collections of local files. - -### Getting started - -To try out the new Content Layer API, enable it in your Astro config: - -```js -import { defineConfig } from 'astro'; - -export default defineConfig({ - experimental: { - contentLayer: true - } -}) -``` - -You can then create collections in your `src/content/config.ts` using the Content Layer API. - -### Loading your content - -The core of the new Content Layer API is the loader, a function that fetches content from a source and caches it in a local data store. Astro 4.14 ships with built-in `glob()` and `file()` loaders to handle your local Markdown, MDX, Markdoc, and JSON files: - -```ts {3,7} -// src/content/config.ts -import { defineCollection, z } from 'astro:content'; -import { glob } from 'astro/loaders'; - -const blog = defineCollection({ - // The ID is a slug generated from the path of the file relative to `base` - loader: glob({ pattern: "**/*.md", base: "./src/data/blog" }), - schema: z.object({ - title: z.string(), - description: z.string(), - publishDate: z.coerce.date(), - }) -}); - -export const collections = { blog }; -``` - -You can then query using the existing content collections functions, and enjoy a simplified `render()` function to display your content: - -```astro ---- -import { getEntry, render } from 'astro:content'; - -const post = await getEntry('blog', Astro.params.slug); - -const { Content } = await render(entry); ---- - -<Content /> -``` - -### Creating a loader - -You're not restricted to the built-in loaders – we hope you'll try building your own. You can fetch content from anywhere and return an array of entries: - -```ts -// src/content/config.ts -const countries = defineCollection({ - loader: async () => { - const response = await fetch("https://restcountries.com/v3.1/all"); - const data = await response.json(); - // Must return an array of entries with an id property, - // or an object with IDs as keys and entries as values - return data.map((country) => ({ - id: country.cca3, - ...country, - })); - }, - // optionally add a schema to validate the data and make it type-safe for users - // schema: z.object... -}); - -export const collections = { countries }; -``` - -For more advanced loading logic, you can define an object loader. This allows incremental updates and conditional loading, and gives full access to the data store. It also allows a loader to define its own schema, including generating it dynamically based on the source API. See the [the Content Layer API RFC](https://github.com/withastro/roadmap/blob/content-layer/proposals/0047-content-layer.md#loaders) for more details. - -### Sharing your loaders - -Loaders are better when they're shared. You can create a package that exports a loader and publish it to npm, and then anyone can use it on their site. We're excited to see what the community comes up with! To get started, [take a look at some examples](https://github.com/ascorbic/astro-loaders/). Here's how to load content using an RSS/Atom feed loader: - -```ts -// src/content/config.ts -import { defineCollection } from "astro:content"; -import { feedLoader } from "@ascorbic/feed-loader"; - -const podcasts = defineCollection({ - loader: feedLoader({ - url: "https://feeds.99percentinvisible.org/99percentinvisible", - }), -}); - -export const collections = { podcasts }; -``` - -### Learn more - -To find out more about using the Content Layer API, check out [the Content Layer RFC](https://github.com/withastro/roadmap/blob/content-layer/proposals/0047-content-layer.md) and [share your feedback](https://github.com/withastro/roadmap/pull/982). diff --git a/examples/basics/package.json b/examples/basics/package.json index 02e40cb4c..ea1fe90c0 100644 --- a/examples/basics/package.json +++ b/examples/basics/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.13.4" + "astro": "^4.14.0" } } diff --git a/examples/blog/package.json b/examples/blog/package.json index 667fceb41..76f9b97fe 100644 --- a/examples/blog/package.json +++ b/examples/blog/package.json @@ -14,6 +14,6 @@ "@astrojs/mdx": "^3.1.3", "@astrojs/rss": "^4.0.7", "@astrojs/sitemap": "^3.1.6", - "astro": "^4.13.4" + "astro": "^4.14.0" } } diff --git a/examples/component/package.json b/examples/component/package.json index 6e4ce727e..4e31293b2 100644 --- a/examples/component/package.json +++ b/examples/component/package.json @@ -15,7 +15,7 @@ ], "scripts": {}, "devDependencies": { - "astro": "^4.13.4" + "astro": "^4.14.0" }, "peerDependencies": { "astro": "^4.0.0" diff --git a/examples/container-with-vitest/package.json b/examples/container-with-vitest/package.json index 7bddf6df4..0d7e206da 100644 --- a/examples/container-with-vitest/package.json +++ b/examples/container-with-vitest/package.json @@ -12,7 +12,7 @@ "test": "vitest run" }, "dependencies": { - "astro": "^4.13.4", + "astro": "^4.14.0", "@astrojs/react": "^3.6.2", "react": "^18.3.1", "react-dom": "^18.3.1", diff --git a/examples/framework-alpine/package.json b/examples/framework-alpine/package.json index 0de84cbbe..0a48c7eeb 100644 --- a/examples/framework-alpine/package.json +++ b/examples/framework-alpine/package.json @@ -14,6 +14,6 @@ "@astrojs/alpinejs": "^0.4.0", "@types/alpinejs": "^3.13.10", "alpinejs": "^3.14.1", - "astro": "^4.13.4" + "astro": "^4.14.0" } } diff --git a/examples/framework-lit/package.json b/examples/framework-lit/package.json index 638a28be0..9a9aee995 100644 --- a/examples/framework-lit/package.json +++ b/examples/framework-lit/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/lit": "^4.3.0", "@webcomponents/template-shadowroot": "^0.2.1", - "astro": "^4.13.4", + "astro": "^4.14.0", "lit": "^3.2.0" } } diff --git a/examples/framework-multiple/package.json b/examples/framework-multiple/package.json index 800f0b0b6..7e71917c4 100644 --- a/examples/framework-multiple/package.json +++ b/examples/framework-multiple/package.json @@ -18,7 +18,7 @@ "@astrojs/vue": "^4.5.0", "@types/react": "^18.3.3", "@types/react-dom": "^18.3.0", - "astro": "^4.13.4", + "astro": "^4.14.0", "preact": "^10.23.1", "react": "^18.3.1", "react-dom": "^18.3.1", diff --git a/examples/framework-preact/package.json b/examples/framework-preact/package.json index 42cf975fc..9d372fc0c 100644 --- a/examples/framework-preact/package.json +++ b/examples/framework-preact/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/preact": "^3.5.1", "@preact/signals": "^1.3.0", - "astro": "^4.13.4", + "astro": "^4.14.0", "preact": "^10.23.1" } } diff --git a/examples/framework-react/package.json b/examples/framework-react/package.json index 8228bf556..85eebf19d 100644 --- a/examples/framework-react/package.json +++ b/examples/framework-react/package.json @@ -14,7 +14,7 @@ "@astrojs/react": "^3.6.2", "@types/react": "^18.3.3", "@types/react-dom": "^18.3.0", - "astro": "^4.13.4", + "astro": "^4.14.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 5152ce823..e6ff05289 100644 --- a/examples/framework-solid/package.json +++ b/examples/framework-solid/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/solid-js": "^4.4.1", - "astro": "^4.13.4", + "astro": "^4.14.0", "solid-js": "^1.8.20" } } diff --git a/examples/framework-svelte/package.json b/examples/framework-svelte/package.json index cc89304bb..8ba82634c 100644 --- a/examples/framework-svelte/package.json +++ b/examples/framework-svelte/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/svelte": "^5.7.0", - "astro": "^4.13.4", + "astro": "^4.14.0", "svelte": "^4.2.18" } } diff --git a/examples/framework-vue/package.json b/examples/framework-vue/package.json index 3cd8d2325..47e1350f8 100644 --- a/examples/framework-vue/package.json +++ b/examples/framework-vue/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/vue": "^4.5.0", - "astro": "^4.13.4", + "astro": "^4.14.0", "vue": "^3.4.37" } } diff --git a/examples/hackernews/package.json b/examples/hackernews/package.json index 836cb8486..3995d8cc1 100644 --- a/examples/hackernews/package.json +++ b/examples/hackernews/package.json @@ -12,6 +12,6 @@ }, "dependencies": { "@astrojs/node": "^8.3.3", - "astro": "^4.13.4" + "astro": "^4.14.0" } } diff --git a/examples/integration/package.json b/examples/integration/package.json index 044510712..ee2571c17 100644 --- a/examples/integration/package.json +++ b/examples/integration/package.json @@ -15,7 +15,7 @@ ], "scripts": {}, "devDependencies": { - "astro": "^4.13.4" + "astro": "^4.14.0" }, "peerDependencies": { "astro": "^4.0.0" diff --git a/examples/middleware/package.json b/examples/middleware/package.json index b86e1b311..990761c2f 100644 --- a/examples/middleware/package.json +++ b/examples/middleware/package.json @@ -13,7 +13,7 @@ }, "dependencies": { "@astrojs/node": "^8.3.3", - "astro": "^4.13.4", + "astro": "^4.14.0", "html-minifier": "^4.0.0" }, "devDependencies": { diff --git a/examples/minimal/package.json b/examples/minimal/package.json index a2892c7e4..27cf53e00 100644 --- a/examples/minimal/package.json +++ b/examples/minimal/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.13.4" + "astro": "^4.14.0" } } diff --git a/examples/non-html-pages/package.json b/examples/non-html-pages/package.json index a6dc53a80..43813bbcd 100644 --- a/examples/non-html-pages/package.json +++ b/examples/non-html-pages/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.13.4" + "astro": "^4.14.0" } } diff --git a/examples/portfolio/package.json b/examples/portfolio/package.json index 1e2b79ea0..e16e5e931 100644 --- a/examples/portfolio/package.json +++ b/examples/portfolio/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.13.4" + "astro": "^4.14.0" } } diff --git a/examples/server-islands/package.json b/examples/server-islands/package.json index 3a1ae97fb..b4e66b951 100644 --- a/examples/server-islands/package.json +++ b/examples/server-islands/package.json @@ -17,7 +17,7 @@ "@tailwindcss/forms": "^0.5.7", "@types/react": "^18.3.3", "@types/react-dom": "^18.3.0", - "astro": "^4.13.4", + "astro": "^4.14.0", "postcss": "^8.4.41", "react": "^18.3.1", "react-dom": "^18.3.1", diff --git a/examples/ssr/package.json b/examples/ssr/package.json index 10703eb9d..5251c90c3 100644 --- a/examples/ssr/package.json +++ b/examples/ssr/package.json @@ -14,7 +14,7 @@ "dependencies": { "@astrojs/node": "^8.3.3", "@astrojs/svelte": "^5.7.0", - "astro": "^4.13.4", + "astro": "^4.14.0", "svelte": "^4.2.18" } } diff --git a/examples/starlog/package.json b/examples/starlog/package.json index 33e546e77..2cff7650b 100644 --- a/examples/starlog/package.json +++ b/examples/starlog/package.json @@ -10,7 +10,7 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.13.4", + "astro": "^4.14.0", "sass": "^1.77.8", "sharp": "^0.33.3" } diff --git a/examples/toolbar-app/package.json b/examples/toolbar-app/package.json index 6f147be74..73537e8ab 100644 --- a/examples/toolbar-app/package.json +++ b/examples/toolbar-app/package.json @@ -15,6 +15,6 @@ "./app": "./dist/app.js" }, "devDependencies": { - "astro": "^4.13.4" + "astro": "^4.14.0" } } diff --git a/examples/view-transitions/package.json b/examples/view-transitions/package.json index 6328e7665..0e05cd142 100644 --- a/examples/view-transitions/package.json +++ b/examples/view-transitions/package.json @@ -12,6 +12,6 @@ "devDependencies": { "@astrojs/tailwind": "^5.1.0", "@astrojs/node": "^8.3.3", - "astro": "^4.13.4" + "astro": "^4.14.0" } } diff --git a/examples/with-markdoc/package.json b/examples/with-markdoc/package.json index dcf8596bd..ddf843fae 100644 --- a/examples/with-markdoc/package.json +++ b/examples/with-markdoc/package.json @@ -12,6 +12,6 @@ }, "dependencies": { "@astrojs/markdoc": "^0.11.3", - "astro": "^4.13.4" + "astro": "^4.14.0" } } diff --git a/examples/with-markdown-plugins/package.json b/examples/with-markdown-plugins/package.json index 407130b83..641a8cb8c 100644 --- a/examples/with-markdown-plugins/package.json +++ b/examples/with-markdown-plugins/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/markdown-remark": "^5.2.0", - "astro": "^4.13.4", + "astro": "^4.14.0", "hast-util-select": "^6.0.2", "rehype-autolink-headings": "^7.1.0", "rehype-slug": "^6.0.0", diff --git a/examples/with-markdown-shiki/package.json b/examples/with-markdown-shiki/package.json index 8a32a5f36..71eca6318 100644 --- a/examples/with-markdown-shiki/package.json +++ b/examples/with-markdown-shiki/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.13.4" + "astro": "^4.14.0" } } diff --git a/examples/with-mdx/package.json b/examples/with-mdx/package.json index 8782c588c..23a57015b 100644 --- a/examples/with-mdx/package.json +++ b/examples/with-mdx/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/mdx": "^3.1.3", "@astrojs/preact": "^3.5.1", - "astro": "^4.13.4", + "astro": "^4.14.0", "preact": "^10.23.1" } } diff --git a/examples/with-nanostores/package.json b/examples/with-nanostores/package.json index 2c73ab734..f700f300d 100644 --- a/examples/with-nanostores/package.json +++ b/examples/with-nanostores/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/preact": "^3.5.1", "@nanostores/preact": "^0.5.2", - "astro": "^4.13.4", + "astro": "^4.14.0", "nanostores": "^0.11.2", "preact": "^10.23.1" } diff --git a/examples/with-tailwindcss/package.json b/examples/with-tailwindcss/package.json index 16cb073c7..5f8e023b1 100644 --- a/examples/with-tailwindcss/package.json +++ b/examples/with-tailwindcss/package.json @@ -14,7 +14,7 @@ "@astrojs/mdx": "^3.1.3", "@astrojs/tailwind": "^5.1.0", "@types/canvas-confetti": "^1.6.4", - "astro": "^4.13.4", + "astro": "^4.14.0", "autoprefixer": "^10.4.20", "canvas-confetti": "^1.9.3", "postcss": "^8.4.41", diff --git a/examples/with-vitest/package.json b/examples/with-vitest/package.json index 2bc1e2d03..15a3f58d0 100644 --- a/examples/with-vitest/package.json +++ b/examples/with-vitest/package.json @@ -12,7 +12,7 @@ "test": "vitest" }, "dependencies": { - "astro": "^4.13.4", + "astro": "^4.14.0", "vitest": "^2.0.5" } } diff --git a/packages/astro/CHANGELOG.md b/packages/astro/CHANGELOG.md index 9db8916b2..8f6e75407 100644 --- a/packages/astro/CHANGELOG.md +++ b/packages/astro/CHANGELOG.md @@ -1,5 +1,227 @@ # astro +## 4.14.0 + +### Minor Changes + +- [#11657](https://github.com/withastro/astro/pull/11657) [`a23c69d`](https://github.com/withastro/astro/commit/a23c69d0d0bed229bee52a32e61f135f9ebf9122) Thanks [@bluwy](https://github.com/bluwy)! - Deprecates the option for route-generating files to export a dynamic value for `prerender`. Only static values are now supported (e.g. `export const prerender = true` or `= false`). This allows for better treeshaking and bundling configuration in the future. + + Adds a new [`"astro:route:setup"` hook](https://docs.astro.build/en/reference/integrations-reference/#astroroutesetup) to the Integrations API to allow you to dynamically set options for a route at build or request time through an integration, such as enabling [on-demand server rendering](https://docs.astro.build/en/guides/server-side-rendering/#opting-in-to-pre-rendering-in-server-mode). + + To migrate from a dynamic export to the new hook, update or remove any dynamic `prerender` exports from individual routing files: + + ```diff + // src/pages/blog/[slug].astro + - export const prerender = import.meta.env.PRERENDER + ``` + + Instead, create an integration with the `"astro:route:setup"` hook and update the route's `prerender` option: + + ```js + // astro.config.mjs + import { defineConfig } from 'astro/config'; + import { loadEnv } from 'vite'; + + export default defineConfig({ + integrations: [setPrerender()], + }); + + function setPrerender() { + const { PRERENDER } = loadEnv(process.env.NODE_ENV, process.cwd(), ''); + + return { + name: 'set-prerender', + hooks: { + 'astro:route:setup': ({ route }) => { + if (route.component.endsWith('/blog/[slug].astro')) { + route.prerender = PRERENDER; + } + }, + }, + }; + } + ``` + +- [#11360](https://github.com/withastro/astro/pull/11360) [`a79a8b0`](https://github.com/withastro/astro/commit/a79a8b0230b06ed32ce1802f2a5f84a6cf92dbe7) Thanks [@ascorbic](https://github.com/ascorbic)! - Adds a new [`injectTypes()` utility](https://docs.astro.build/en/reference/integrations-reference/#injecttypes-options) to the Integration API and refactors how type generation works + + Use `injectTypes()` in the `astro:config:done` hook to inject types into your user's project by adding a new a `*.d.ts` file. + + The `filename` property will be used to generate a file at `/.astro/integrations/<normalized_integration_name>/<normalized_filename>.d.ts` and must end with `".d.ts"`. + + The `content` property will create the body of the file, and must be valid TypeScript. + + Additionally, `injectTypes()` returns a URL to the normalized path so you can overwrite its content later on, or manipulate it in any way you want. + + ```js + // my-integration/index.js + export default { + name: 'my-integration', + 'astro:config:done': ({ injectTypes }) => { + injectTypes({ + filename: 'types.d.ts', + content: "declare module 'virtual:my-integration' {}", + }); + }, + }; + ``` + + Codegen has been refactored. Although `src/env.d.ts` will continue to work as is, we recommend you update it: + + ```diff + - /// <reference types="astro/client" /> + + /// <reference path="../.astro/types.d.ts" /> + - /// <reference path="../.astro/env.d.ts" /> + - /// <reference path="../.astro/actions.d.ts" /> + ``` + +- [#11605](https://github.com/withastro/astro/pull/11605) [`d3d99fb`](https://github.com/withastro/astro/commit/d3d99fba269da9e812e748539a11dfed785ef8a4) Thanks [@jcayzac](https://github.com/jcayzac)! - Adds a new property `meta` to Astro's [built-in `<Code />` component](https://docs.astro.build/en/reference/api-reference/#code-). + + This allows you to provide a value for [Shiki's `meta` attribute](https://shiki.style/guide/transformers#meta) to pass options to transformers. + + The following example passes an option to highlight lines 1 and 3 to Shiki's `tranformerMetaHighlight`: + + ```astro + --- + // src/components/Card.astro + import { Code } from 'astro:components'; + import { transformerMetaHighlight } from '@shikijs/transformers'; + --- + + <Code code={code} lang="js" transformers={[transformerMetaHighlight()]} meta="{1,3}" /> + ``` + +- [#11360](https://github.com/withastro/astro/pull/11360) [`a79a8b0`](https://github.com/withastro/astro/commit/a79a8b0230b06ed32ce1802f2a5f84a6cf92dbe7) Thanks [@ascorbic](https://github.com/ascorbic)! - Adds support for Intellisense features (e.g. code completion, quick hints) for your content collection entries in compatible editors under the `experimental.contentIntellisense` flag. + + ```js + import { defineConfig } from 'astro'; + + export default defineConfig({ + experimental: { + contentIntellisense: true, + }, + }); + ``` + + When enabled, this feature will generate and add JSON schemas to the `.astro` directory in your project. These files can be used by the Astro language server to provide Intellisense inside content files (`.md`, `.mdx`, `.mdoc`). + + Note that at this time, this also require enabling the `astro.content-intellisense` option in your editor, or passing the `contentIntellisense: true` initialization parameter to the Astro language server for editors using it directly. + + See the [experimental content Intellisense docs](https://docs.astro.build/en/reference/configuration-reference/#experimentalcontentintellisense) for more information updates as this feature develops. + +- [#11360](https://github.com/withastro/astro/pull/11360) [`a79a8b0`](https://github.com/withastro/astro/commit/a79a8b0230b06ed32ce1802f2a5f84a6cf92dbe7) Thanks [@ascorbic](https://github.com/ascorbic)! - Adds experimental support for the Content Layer API. + + The new Content Layer API builds upon content collections, taking them beyond local files in `src/content/` and allowing you to fetch content from anywhere, including remote APIs. These new collections work alongside your existing content collections, and you can migrate them to the new API at your own pace. There are significant improvements to performance with large collections of local files. + + ### Getting started + + To try out the new Content Layer API, enable it in your Astro config: + + ```js + import { defineConfig } from 'astro'; + + export default defineConfig({ + experimental: { + contentLayer: true, + }, + }); + ``` + + You can then create collections in your `src/content/config.ts` using the Content Layer API. + + ### Loading your content + + The core of the new Content Layer API is the loader, a function that fetches content from a source and caches it in a local data store. Astro 4.14 ships with built-in `glob()` and `file()` loaders to handle your local Markdown, MDX, Markdoc, and JSON files: + + ```ts {3,7} + // src/content/config.ts + import { defineCollection, z } from 'astro:content'; + import { glob } from 'astro/loaders'; + + const blog = defineCollection({ + // The ID is a slug generated from the path of the file relative to `base` + loader: glob({ pattern: '**/*.md', base: './src/data/blog' }), + schema: z.object({ + title: z.string(), + description: z.string(), + publishDate: z.coerce.date(), + }), + }); + + export const collections = { blog }; + ``` + + You can then query using the existing content collections functions, and enjoy a simplified `render()` function to display your content: + + ```astro + --- + import { getEntry, render } from 'astro:content'; + + const post = await getEntry('blog', Astro.params.slug); + + const { Content } = await render(entry); + --- + + <Content /> + ``` + + ### Creating a loader + + You're not restricted to the built-in loaders – we hope you'll try building your own. You can fetch content from anywhere and return an array of entries: + + ```ts + // src/content/config.ts + const countries = defineCollection({ + loader: async () => { + const response = await fetch('https://restcountries.com/v3.1/all'); + const data = await response.json(); + // Must return an array of entries with an id property, + // or an object with IDs as keys and entries as values + return data.map((country) => ({ + id: country.cca3, + ...country, + })); + }, + // optionally add a schema to validate the data and make it type-safe for users + // schema: z.object... + }); + + export const collections = { countries }; + ``` + + For more advanced loading logic, you can define an object loader. This allows incremental updates and conditional loading, and gives full access to the data store. It also allows a loader to define its own schema, including generating it dynamically based on the source API. See the [the Content Layer API RFC](https://github.com/withastro/roadmap/blob/content-layer/proposals/0047-content-layer.md#loaders) for more details. + + ### Sharing your loaders + + Loaders are better when they're shared. You can create a package that exports a loader and publish it to npm, and then anyone can use it on their site. We're excited to see what the community comes up with! To get started, [take a look at some examples](https://github.com/ascorbic/astro-loaders/). Here's how to load content using an RSS/Atom feed loader: + + ```ts + // src/content/config.ts + import { defineCollection } from 'astro:content'; + import { feedLoader } from '@ascorbic/feed-loader'; + + const podcasts = defineCollection({ + loader: feedLoader({ + url: 'https://feeds.99percentinvisible.org/99percentinvisible', + }), + }); + + export const collections = { podcasts }; + ``` + + ### Learn more + + To find out more about using the Content Layer API, check out [the Content Layer RFC](https://github.com/withastro/roadmap/blob/content-layer/proposals/0047-content-layer.md) and [share your feedback](https://github.com/withastro/roadmap/pull/982). + +### Patch Changes + +- [#11716](https://github.com/withastro/astro/pull/11716) [`f4057c1`](https://github.com/withastro/astro/commit/f4057c18c91f969e3e508545fb988aff94c3ff08) Thanks [@florian-lefebvre](https://github.com/florian-lefebvre)! - Fixes content types sync in dev + +- [#11645](https://github.com/withastro/astro/pull/11645) [`849e4c6`](https://github.com/withastro/astro/commit/849e4c6c23e61f7fa59f583419048b998bef2475) Thanks [@bluwy](https://github.com/bluwy)! - Refactors internally to use `node:util` `parseArgs` instead of `yargs-parser` + +- [#11712](https://github.com/withastro/astro/pull/11712) [`791d809`](https://github.com/withastro/astro/commit/791d809cbc22ed30dda1195ca026daa46a54b551) Thanks [@matthewp](https://github.com/matthewp)! - Fix mixed use of base + trailingSlash in Server Islands + +- [#11709](https://github.com/withastro/astro/pull/11709) [`3d8ae76`](https://github.com/withastro/astro/commit/3d8ae767fd4952af7332542b58fe98886eb2e99e) Thanks [@matthewp](https://github.com/matthewp)! - Fix adapter causing Netlify to break + ## 4.13.4 ### Patch Changes diff --git a/packages/astro/package.json b/packages/astro/package.json index 31591eb29..e8f53ee8f 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -1,6 +1,6 @@ { "name": "astro", - "version": "4.13.4", + "version": "4.14.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/create-astro/CHANGELOG.md b/packages/create-astro/CHANGELOG.md index 5af50e312..600e9f8e6 100644 --- a/packages/create-astro/CHANGELOG.md +++ b/packages/create-astro/CHANGELOG.md @@ -1,5 +1,11 @@ # create-astro +## 4.8.2 + +### Patch Changes + +- [#11645](https://github.com/withastro/astro/pull/11645) [`849e4c6`](https://github.com/withastro/astro/commit/849e4c6c23e61f7fa59f583419048b998bef2475) Thanks [@bluwy](https://github.com/bluwy)! - Refactors internally to use `node:util` `parseArgs` instead of `arg` + ## 4.8.1 ### Patch Changes diff --git a/packages/create-astro/package.json b/packages/create-astro/package.json index 4a2fc13ad..79cea9ce9 100644 --- a/packages/create-astro/package.json +++ b/packages/create-astro/package.json @@ -1,6 +1,6 @@ { "name": "create-astro", - "version": "4.8.1", + "version": "4.8.2", "type": "module", "author": "withastro", "license": "MIT", diff --git a/packages/db/CHANGELOG.md b/packages/db/CHANGELOG.md index eb7978ead..046d3305b 100644 --- a/packages/db/CHANGELOG.md +++ b/packages/db/CHANGELOG.md @@ -1,5 +1,31 @@ # @astrojs/db +## 0.13.0 + +### Minor Changes + +- [#11360](https://github.com/withastro/astro/pull/11360) [`a79a8b0`](https://github.com/withastro/astro/commit/a79a8b0230b06ed32ce1802f2a5f84a6cf92dbe7) Thanks [@ascorbic](https://github.com/ascorbic)! - Changes how type generation works + + The generated `.d.ts` file is now at a new location: + + ```diff + - .astro/db-types.d.ts + + .astro/integrations/astro_db/db.d.ts + ``` + + The following line can now be removed from `src/env.d.ts`: + + ```diff + - /// <reference path="../.astro/db-types.d.ts" /> + ``` + +### Patch Changes + +- [#11645](https://github.com/withastro/astro/pull/11645) [`849e4c6`](https://github.com/withastro/astro/commit/849e4c6c23e61f7fa59f583419048b998bef2475) Thanks [@bluwy](https://github.com/bluwy)! - Refactors internally to use `node:util` `parseArgs` instead of `yargs-parser` + +- Updated dependencies []: + - @astrojs/studio@0.1.1 + ## 0.12.0 ### Minor Changes diff --git a/packages/db/package.json b/packages/db/package.json index 6dd5d5823..b92e47fe6 100644 --- a/packages/db/package.json +++ b/packages/db/package.json @@ -1,6 +1,6 @@ { "name": "@astrojs/db", - "version": "0.12.0", + "version": "0.13.0", "description": "Add libSQL and Astro Studio support to your Astro site", "license": "MIT", "repository": { diff --git a/packages/integrations/web-vitals/CHANGELOG.md b/packages/integrations/web-vitals/CHANGELOG.md index 3d5628824..037e868a9 100644 --- a/packages/integrations/web-vitals/CHANGELOG.md +++ b/packages/integrations/web-vitals/CHANGELOG.md @@ -1,5 +1,12 @@ # @astrojs/web-vitals +## 2.0.0 + +### Patch Changes + +- Updated dependencies [[`849e4c6`](https://github.com/withastro/astro/commit/849e4c6c23e61f7fa59f583419048b998bef2475), [`a79a8b0`](https://github.com/withastro/astro/commit/a79a8b0230b06ed32ce1802f2a5f84a6cf92dbe7)]: + - @astrojs/db@0.13.0 + ## 1.0.0 ### Patch Changes diff --git a/packages/integrations/web-vitals/package.json b/packages/integrations/web-vitals/package.json index 7ae27f247..fcf42d536 100644 --- a/packages/integrations/web-vitals/package.json +++ b/packages/integrations/web-vitals/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/web-vitals", "description": "Track your website’s performance with Astro DB", - "version": "1.0.0", + "version": "2.0.0", "type": "module", "author": "withastro", "license": "MIT", @@ -35,7 +35,7 @@ "web-vitals": "^4.2.3" }, "peerDependencies": { - "@astrojs/db": "^0.12.0" + "@astrojs/db": "^0.13.0" }, "devDependencies": { "@astrojs/db": "workspace:*", diff --git a/packages/upgrade/CHANGELOG.md b/packages/upgrade/CHANGELOG.md index c4e7da9cf..b0c80a869 100644 --- a/packages/upgrade/CHANGELOG.md +++ b/packages/upgrade/CHANGELOG.md @@ -1,5 +1,11 @@ # @astrojs/upgrade +## 0.3.2 + +### Patch Changes + +- [#11645](https://github.com/withastro/astro/pull/11645) [`849e4c6`](https://github.com/withastro/astro/commit/849e4c6c23e61f7fa59f583419048b998bef2475) Thanks [@bluwy](https://github.com/bluwy)! - Refactors internally to use `node:util` `parseArgs` instead of `arg` + ## 0.3.1 ### Patch Changes diff --git a/packages/upgrade/package.json b/packages/upgrade/package.json index fe36ecd24..3f005e1f8 100644 --- a/packages/upgrade/package.json +++ b/packages/upgrade/package.json @@ -1,6 +1,6 @@ { "name": "@astrojs/upgrade", - "version": "0.3.1", + "version": "0.3.2", "type": "module", "author": "withastro", "license": "MIT", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6f548f030..c83e577de 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -116,7 +116,7 @@ importers: examples/basics: dependencies: astro: - specifier: ^4.13.4 + specifier: ^4.14.0 version: link:../../packages/astro examples/blog: @@ -131,13 +131,13 @@ importers: specifier: ^3.1.6 version: link:../../packages/integrations/sitemap astro: - specifier: ^4.13.4 + specifier: ^4.14.0 version: link:../../packages/astro examples/component: devDependencies: astro: - specifier: ^4.13.4 + specifier: ^4.14.0 version: link:../../packages/astro examples/container-with-vitest: @@ -146,7 +146,7 @@ importers: specifier: ^3.6.2 version: link:../../packages/integrations/react astro: - specifier: ^4.13.4 + specifier: ^4.14.0 version: link:../../packages/astro react: specifier: ^18.3.1 @@ -177,7 +177,7 @@ importers: specifier: ^3.14.1 version: 3.14.1 astro: - specifier: ^4.13.4 + specifier: ^4.14.0 version: link:../../packages/astro examples/framework-lit: @@ -189,7 +189,7 @@ importers: specifier: ^0.2.1 version: 0.2.1 astro: - specifier: ^4.13.4 + specifier: ^4.14.0 version: link:../../packages/astro lit: specifier: ^3.2.0 @@ -219,7 +219,7 @@ importers: specifier: ^18.3.0 version: 18.3.0 astro: - specifier: ^4.13.4 + specifier: ^4.14.0 version: link:../../packages/astro preact: specifier: ^10.23.1 @@ -249,7 +249,7 @@ importers: specifier: ^1.3.0 version: 1.3.0(preact@10.23.1) astro: - specifier: ^4.13.4 + specifier: ^4.14.0 version: link:../../packages/astro preact: specifier: ^10.23.1 @@ -267,7 +267,7 @@ importers: specifier: ^18.3.0 version: 18.3.0 astro: - specifier: ^4.13.4 + specifier: ^4.14.0 version: link:../../packages/astro react: specifier: ^18.3.1 @@ -282,7 +282,7 @@ importers: specifier: ^4.4.1 version: link:../../packages/integrations/solid astro: - specifier: ^4.13.4 + specifier: ^4.14.0 version: link:../../packages/astro solid-js: specifier: ^1.8.20 @@ -294,7 +294,7 @@ importers: specifier: ^5.7.0 version: link:../../packages/integrations/svelte astro: - specifier: ^4.13.4 + specifier: ^4.14.0 version: link:../../packages/astro svelte: specifier: ^4.2.18 @@ -306,7 +306,7 @@ importers: specifier: ^4.5.0 version: link:../../packages/integrations/vue astro: - specifier: ^4.13.4 + specifier: ^4.14.0 version: link:../../packages/astro vue: specifier: ^3.4.37 @@ -318,13 +318,13 @@ importers: specifier: ^8.3.3 version: link:../../packages/integrations/node astro: - specifier: ^4.13.4 + specifier: ^4.14.0 version: link:../../packages/astro examples/integration: devDependencies: astro: - specifier: ^4.13.4 + specifier: ^4.14.0 version: link:../../packages/astro examples/middleware: @@ -333,7 +333,7 @@ importers: specifier: ^8.3.3 version: link:../../packages/integrations/node astro: - specifier: ^4.13.4 + specifier: ^4.14.0 version: link:../../packages/astro html-minifier: specifier: ^4.0.0 @@ -346,19 +346,19 @@ importers: examples/minimal: dependencies: astro: - specifier: ^4.13.4 + specifier: ^4.14.0 version: link:../../packages/astro examples/non-html-pages: dependencies: astro: - specifier: ^4.13.4 + specifier: ^4.14.0 version: link:../../packages/astro examples/portfolio: dependencies: astro: - specifier: ^4.13.4 + specifier: ^4.14.0 version: link:../../packages/astro examples/server-islands: @@ -385,7 +385,7 @@ importers: specifier: ^18.3.0 version: 18.3.0 astro: - specifier: ^4.13.4 + specifier: ^4.14.0 version: link:../../packages/astro postcss: specifier: ^8.4.41 @@ -409,7 +409,7 @@ importers: specifier: ^5.7.0 version: link:../../packages/integrations/svelte astro: - specifier: ^4.13.4 + specifier: ^4.14.0 version: link:../../packages/astro svelte: specifier: ^4.2.18 @@ -418,7 +418,7 @@ importers: examples/starlog: dependencies: astro: - specifier: ^4.13.4 + specifier: ^4.14.0 version: link:../../packages/astro sass: specifier: ^1.77.8 @@ -430,7 +430,7 @@ importers: examples/toolbar-app: devDependencies: astro: - specifier: ^4.13.4 + specifier: ^4.14.0 version: link:../../packages/astro examples/view-transitions: @@ -442,7 +442,7 @@ importers: specifier: ^5.1.0 version: link:../../packages/integrations/tailwind astro: - specifier: ^4.13.4 + specifier: ^4.14.0 version: link:../../packages/astro examples/with-markdoc: @@ -451,7 +451,7 @@ importers: specifier: ^0.11.3 version: link:../../packages/integrations/markdoc astro: - specifier: ^4.13.4 + specifier: ^4.14.0 version: link:../../packages/astro examples/with-markdown-plugins: @@ -460,7 +460,7 @@ importers: specifier: ^5.2.0 version: link:../../packages/markdown/remark astro: - specifier: ^4.13.4 + specifier: ^4.14.0 version: link:../../packages/astro hast-util-select: specifier: ^6.0.2 @@ -481,7 +481,7 @@ importers: examples/with-markdown-shiki: dependencies: astro: - specifier: ^4.13.4 + specifier: ^4.14.0 version: link:../../packages/astro examples/with-mdx: @@ -493,7 +493,7 @@ importers: specifier: ^3.5.1 version: link:../../packages/integrations/preact astro: - specifier: ^4.13.4 + specifier: ^4.14.0 version: link:../../packages/astro preact: specifier: ^10.23.1 @@ -508,7 +508,7 @@ importers: specifier: ^0.5.2 version: 0.5.2(nanostores@0.11.2)(preact@10.23.1) astro: - specifier: ^4.13.4 + specifier: ^4.14.0 version: link:../../packages/astro nanostores: specifier: ^0.11.2 @@ -529,7 +529,7 @@ importers: specifier: ^1.6.4 version: 1.6.4 astro: - specifier: ^4.13.4 + specifier: ^4.14.0 version: link:../../packages/astro autoprefixer: specifier: ^10.4.20 @@ -547,7 +547,7 @@ importers: examples/with-vitest: dependencies: astro: - specifier: ^4.13.4 + specifier: ^4.14.0 version: link:../../packages/astro vitest: specifier: ^2.0.5 |