Major Changes
-
#5941
304823811
Thanks @bholmesdev! - Content collections: Introduce a newslug
frontmatter field for overriding the generated slug. This replaces the previousslug()
collection config option from Astro 1.X and the 2.0 beta.When present in a Markdown or MDX file, this will override the generated slug for that entry.
# src/content/blog/post-1.md --- title: Post 1 + slug: post-1-custom-slug ---
Astro will respect this slug in the generated
slug
type and when using thegetEntryBySlug()
utility:--- import { getEntryBySlug } from 'astro:content'; // Retrieve `src/content/blog/post-1.md` by slug with type safety const post = await getEntryBySlug('blog', 'post-1-custom-slug'); ---
Migration
If you relied on the
slug()
config option, you will need to move all custom slugs toslug
frontmatter properties in each collection entry.Additionally, Astro no longer allows
slug
as a collection schema property. This ensures Astro can manage theslug
property for type generation and performance. Remove this property from your schema and any relevantslug()
configuration:const blog = defineCollection({ schema: z.object({ - slug: z.string().optional(), }), - slug({ defaultSlug, data }) { - return data.slug ?? defaultSlug; - }, })
Patch Changes
-
#5499
4987d6f44
Thanks @bluwy! - Handle custom injected entry files during build -
#5917
7325df412
Thanks @natemoo-re! - Fix duplicate CSS in dev mode whenvite.css.devSourcemap
is provided -
#5909
5fd9208d4
Thanks @jasikpark! - Update compiler to 1.0.1 -
Updated dependencies [
46ecd5de3
]:- @astrojs/[email protected]