Major Changes
-
#11826
7315050
Thanks @matthewp! - Deprecate Astro.globThe
Astro.glob
function has been deprecated in favor of Content Collections andimport.meta.glob
.- If you want to query for markdown and MDX in your project, use Content Collections.
- If you want to query source files in your project, use
import.meta.glob
(https://vitejs.dev/guide/features.html#glob-import).
Also consider using glob packages from npm, like fast-glob, especially if statically generating your site, as it is faster for most use-cases.
The easiest path is to migrate to
import.meta.glob
like so:- const posts = Astro.glob('./posts/*.md'); + const posts = Object.values(import.meta.glob('./posts/*.md', { eager: true }));
-
#11827
a83e362
Thanks @matthewp! - Prevent usage ofastro:content
in the clientUsage of
astro:content
in the client has always been discouraged because it leads to all of your content winding up in your client bundle, and can possibly leaks secrets.This formally makes doing so impossible, adding to the previous warning with errors.
In the future Astro might add APIs for client-usage based on needs.
-
#11253
4e5cc5a
Thanks @kevinzunigacuellar! - Changes the data returned forpage.url.current
,page.url.next
,page.url.prev
,page.url.first
andpage.url.last
to include the value set forbase
in your Astro config.Previously, you had to manually prepend your configured value for
base
to the URL path. Now, Astro automatically includes yourbase
value innext
andprev
URLs.If you are using the
paginate()
function for "previous" and "next" URLs, remove any existingbase
value as it is now added for you:--- export async function getStaticPaths({ paginate }) { const astronautPages = [{ astronaut: 'Neil Armstrong', }, { astronaut: 'Buzz Aldrin', }, { astronaut: 'Sally Ride', }, { astronaut: 'John Glenn', }]; return paginate(astronautPages, { pageSize: 1 }); } const { page } = Astro.props; // `base: /'docs'` configured in `astro.config.mjs` - const prev = "/docs" + page.url.prev; + const prev = page.url.prev; --- <a id="prev" href={prev}>Back</a>
Minor Changes
-
#11698
05139ef
Thanks @ematipico! - Adds a new property to the globalsAstro
andAPIContext
calledroutePattern
. TheroutePattern
represents the current route (component)
that is being rendered by Astro. It's usually a path pattern will look like this:blog/[slug]
:--- // src/pages/blog/[slug].astro const route = Astro.routePattern; console.log(route); // it will log "blog/[slug]" ---
// src/pages/index.js export const GET = (ctx) => { console.log(ctx.routePattern); // it will log src/pages/index.js return new Response.json({ loreum: 'ipsum' }); };
Patch Changes
-
#11791
9393243
Thanks @bluwy! - Updates Astro's default<script>
rendering strategy and removes theexperimental.directRenderScript
option as this is now the default behavior: scripts are always rendered directly. This new strategy prevents scripts from being executed in pages where they are not used.Scripts will directly render as declared in Astro files (including existing features like TypeScript, importing
node_modules
, and deduplicating scripts). You can also now conditionally render scripts in your Astro file.However, this means scripts are no longer hoisted to the
<head>
, multiple scripts on a page are no longer bundled together, and the<script>
tag may interfere with the CSS styling.As this is a potentially breaking change to your script behavior, please review your
<script>
tags and ensure that they behave as expected. -
#11767
d1bd1a1
Thanks @ascorbic! - Refactors content layer sync to use a queue