diff options
Diffstat (limited to 'packages')
-rw-r--r-- | packages/astro/CHANGELOG.md | 80 | ||||
-rw-r--r-- | packages/astro/package.json | 2 | ||||
-rw-r--r-- | packages/astro/src/content/utils.ts | 2 | ||||
-rw-r--r-- | packages/astro/src/core/config/schema.ts | 5 | ||||
-rw-r--r-- | packages/astro/src/core/create-vite.ts | 2 | ||||
-rw-r--r-- | packages/integrations/svelte/CHANGELOG.md | 6 | ||||
-rw-r--r-- | packages/integrations/svelte/package.json | 2 |
7 files changed, 91 insertions, 8 deletions
diff --git a/packages/astro/CHANGELOG.md b/packages/astro/CHANGELOG.md index 7ce1abcde..a7ad85484 100644 --- a/packages/astro/CHANGELOG.md +++ b/packages/astro/CHANGELOG.md @@ -1,5 +1,85 @@ # astro +## 5.0.0-beta.4 + +### Major Changes + +- [#11979](https://github.com/withastro/astro/pull/11979) [`423dfc1`](https://github.com/withastro/astro/commit/423dfc19ad83661b71151f8cec40701c7ced557b) Thanks [@bluwy](https://github.com/bluwy)! - Bumps `vite` dependency to v6.0.0-beta.2. The version is pinned and will be updated as new Vite versions publish to prevent unhandled breaking changes. For the full list of Vite-specific changes, see [its changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md). + +- [#12100](https://github.com/withastro/astro/pull/12100) [`abf9a89`](https://github.com/withastro/astro/commit/abf9a89ac1eaec9a8934a68aeebe3c502a3b47eb) Thanks [@astrobot-houston](https://github.com/astrobot-houston)! - Refactors legacy `content` and `data` collections to use the Content Layer API `glob()` loader for better performance and to support backwards compatibility. Also introduces the `legacy.collections` flag for projects that are unable to update to the new behavior immediately. + + :warning: **BREAKING CHANGE FOR LEGACY CONTENT COLLECTIONS** :warning: + + By default, collections that use the old types (`content` or `data`) and do not define a `loader` are now implemented under the hood using the Content Layer API's built-in `glob()` loader, with extra backward-compatibility handling. + + In order to achieve backwards compatibility with existing `content` collections, the following have been implemented: + + - a `glob` loader collection is defined, with patterns that match the previous handling (matches `src/content/<collection name>/**/*.md` and other content extensions depending on installed integrations, with underscore-prefixed files and folders ignored) + - When used in the runtime, the entries have an ID based on the filename in the same format as legacy collections + - A `slug` field is added with the same format as before + - A `render()` method is added to the entry, so they can be called using `entry.render()` + - `getEntryBySlug` is supported + + In order to achieve backwards compatibility with existing `data` collections, the following have been implemented: + + - a `glob` loader collection is defined, with patterns that match the previous handling (matches `src/content/<collection name>/**/*{.json,.yaml}` and other data extensions, with underscore-prefixed files and folders ignored) + - Entries have an ID that is not slugified + - `getDataEntryById` is supported + + While this backwards compatibility implementation is able to emulate most of the features of legacy collections, **there are some differences and limitations that may cause breaking changes to existing collections**: + + - In previous versions of Astro, collections would be generated for all folders in `src/content/`, even if they were not defined in `src/content/config.ts`. This behavior is now deprecated, and collections should always be defined in `src/content/config.ts`. For existing collections, these can just be empty declarations (e.g. `const blog = defineCollection({})`) and Astro will implicitly define your legacy collection for you in a way that is compatible with the new loading behavior. + - The special `layout` field is not supported in Markdown collection entries. This property is intended only for standalone page files located in `src/pages/` and not likely to be in your collection entries. However, if you were using this property, you must now create dynamic routes that include your page styling. + - Sort order of generated collections is non-deterministic and platform-dependent. This means that if you are calling `getCollection()`, the order in which entries are returned may be different than before. If you need a specific order, you should sort the collection entries yourself. + - `image().refine()` is not supported. If you need to validate the properties of an image you will need to do this at runtime in your page or component. + - the `key` argument of `getEntry(collection, key)` is typed as `string`, rather than having types for every entry. + + A new legacy configuration flag `legacy.collections` is added for users that want to keep their current legacy (content and data) collections behavior (available in Astro v2 - v4), or who are not yet ready to update their projects: + + ```js + // astro.config.mjs + import { defineConfig } from 'astro/config'; + + export default defineConfig({ + legacy: { + collections: true, + }, + }); + ``` + + When set, no changes to your existing collections are necessary, and the restrictions on storing both new and old collections continue to exist: legacy collections (only) must continue to remain in `src/content/`, while new collections using a loader from the Content Layer API are forbidden in that folder. + +- [#12079](https://github.com/withastro/astro/pull/12079) [`7febf1f`](https://github.com/withastro/astro/commit/7febf1f6b58f2ed014df617bd7162c854cadd230) Thanks [@ematipico](https://github.com/ematipico)! - `params` passed in `getStaticPaths` are no longer automatically decoded. + + ### [changed]: `params` aren't decoded anymore. + + In Astro v4.x, `params` in were automatically decoded using `decodeURIComponent`. + + Astro v5.0 doesn't automatically decode `params` in `getStaticPaths` anymore, so you'll need to manually decode them yourself if needed + + #### What should I do? + + If you were relying on the automatic decode, you'll need to manually decode it using `decodeURI`. + + Note that the use of [`decodeURIComponent`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent)) is discouraged for `getStaticPaths` because it decodes more characters than it should, for example `/`, `?`, `#` and more. + + ```diff + --- + export function getStaticPaths() { + return [ + + { params: { id: decodeURI("%5Bpage%5D") } }, + - { params: { id: "%5Bpage%5D" } }, + ] + } + + const { id } = Astro.params; + --- + ``` + +### Patch Changes + +- [#12127](https://github.com/withastro/astro/pull/12127) [`55e9cd8`](https://github.com/withastro/astro/commit/55e9cd88551ac56ec4cab9a9f3fd9ba49b8934b9) Thanks [@ascorbic](https://github.com/ascorbic)! - Prevents Vite emitting an error when restarting itself + ## 5.0.0-beta.3 ### Minor Changes diff --git a/packages/astro/package.json b/packages/astro/package.json index c169e0f37..a50d3f7c6 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -1,6 +1,6 @@ { "name": "astro", - "version": "5.0.0-beta.3", + "version": "5.0.0-beta.4", "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/astro/src/content/utils.ts b/packages/astro/src/content/utils.ts index 164e357de..05c712be5 100644 --- a/packages/astro/src/content/utils.ts +++ b/packages/astro/src/content/utils.ts @@ -3,6 +3,7 @@ import path from 'node:path'; import { fileURLToPath, pathToFileURL } from 'node:url'; import { parseFrontmatter } from '@astrojs/markdown-remark'; import { slug as githubSlug } from 'github-slugger'; +import { green } from 'kleur/colors'; import type { PluginContext } from 'rollup'; import type { ViteDevServer } from 'vite'; import xxhash from 'xxhash-wasm'; @@ -25,7 +26,6 @@ import { } from './consts.js'; import { glob } from './loaders/glob.js'; import { createImage } from './runtime-assets.js'; -import { green } from 'kleur/colors'; /** * Amap from a collection + slug to the local file path. * This is used internally to resolve entry imports when using `getEntry()`. diff --git a/packages/astro/src/core/config/schema.ts b/packages/astro/src/core/config/schema.ts index fc2018414..eec3d869d 100644 --- a/packages/astro/src/core/config/schema.ts +++ b/packages/astro/src/core/config/schema.ts @@ -526,10 +526,7 @@ export const AstroConfigSchema = z.object({ .default({}), legacy: z .object({ - collections: z - .boolean() - .optional() - .default(ASTRO_CONFIG_DEFAULTS.legacy.collections), + collections: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.legacy.collections), }) .default({}), }); diff --git a/packages/astro/src/core/create-vite.ts b/packages/astro/src/core/create-vite.ts index 8e4806ead..f388efb7e 100644 --- a/packages/astro/src/core/create-vite.ts +++ b/packages/astro/src/core/create-vite.ts @@ -25,6 +25,7 @@ import configAliasVitePlugin from '../vite-plugin-config-alias/index.js'; import envVitePlugin from '../vite-plugin-env/index.js'; import vitePluginFileURL from '../vite-plugin-fileurl/index.js'; import astroHeadPlugin from '../vite-plugin-head/index.js'; +import astroHmrReloadPlugin from '../vite-plugin-hmr-reload/index.js'; import htmlVitePlugin from '../vite-plugin-html/index.js'; import astroIntegrationsContainerPlugin from '../vite-plugin-integrations-container/index.js'; import astroLoadFallbackPlugin from '../vite-plugin-load-fallback/index.js'; @@ -40,7 +41,6 @@ import { vitePluginMiddleware } from './middleware/vite-plugin.js'; import { joinPaths } from './path.js'; import { vitePluginServerIslands } from './server-islands/vite-plugin-server-islands.js'; import { isObject } from './util.js'; -import astroHmrReloadPlugin from '../vite-plugin-hmr-reload/index.js'; type CreateViteOptions = { settings: AstroSettings; diff --git a/packages/integrations/svelte/CHANGELOG.md b/packages/integrations/svelte/CHANGELOG.md index ad175da74..074bf2f60 100644 --- a/packages/integrations/svelte/CHANGELOG.md +++ b/packages/integrations/svelte/CHANGELOG.md @@ -1,5 +1,11 @@ # @astrojs/svelte +## 6.0.0-beta.1 + +### Patch Changes + +- [#12102](https://github.com/withastro/astro/pull/12102) [`dcc1e89`](https://github.com/withastro/astro/commit/dcc1e895abbad1311719803363c933541c0ad984) Thanks [@hermit99](https://github.com/hermit99)! - Fixes an Reference Error that occurred during client transitions + ## 6.0.0-beta.0 ### Major Changes diff --git a/packages/integrations/svelte/package.json b/packages/integrations/svelte/package.json index d9321af19..e5bba1a20 100644 --- a/packages/integrations/svelte/package.json +++ b/packages/integrations/svelte/package.json @@ -1,6 +1,6 @@ { "name": "@astrojs/svelte", - "version": "6.0.0-beta.0", + "version": "6.0.0-beta.1", "description": "Use Svelte components within Astro", "type": "module", "types": "./dist/index.d.ts", |