github withastro/astro astro@5.0.0-alpha.2

latest releases: astro@4.15.8, @astrojs/mdx@3.1.7, astro@4.15.7...
pre-release20 days ago

Major Changes

  • #11826 7315050 Thanks @matthewp! - Deprecate Astro.glob

    The Astro.glob function has been deprecated in favor of Content Collections and import.meta.glob.

    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 of astro:content in the client

    Usage 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 for page.url.current, page.url.next, page.url.prev, page.url.first and page.url.last to include the value set for base in your Astro config.

    Previously, you had to manually prepend your configured value for base to the URL path. Now, Astro automatically includes your base value in next and prev URLs.

    If you are using the paginate() function for "previous" and "next" URLs, remove any existing base 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 globals Astro and APIContext called routePattern. The routePattern 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 the experimental.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

Don't miss a new astro release

NewReleases is sending notifications on new releases.