github withastro/astro astro@3.2.0

latest releases: astro@4.15.8, @astrojs/mdx@3.1.7, astro@4.15.7...
11 months ago

Minor Changes

  • #8696 2167ffd72 Thanks @matthewp! - Support adding integrations dynamically

    Astro integrations can now themselves dynamically add and configure additional integrations during set-up. This makes it possible for integration authors to bundle integrations more intelligently for their users.

    In the following example, a custom integration checks whether @astrojs/sitemap is already configured. If not, the integration adds Astro’s sitemap integration, passing any desired configuration options:

    import sitemap from '@astrojs/sitemap';
    import type { AstroIntegration } from 'astro';
    
    const MyIntegration = (): AstroIntegration => {
      return {
        name: 'my-integration',
    
        'astro:config:setup': ({ config, updateConfig }) => {
          // Look for sitemap in user-configured integrations.
          const userSitemap = config.integrations.find(
            ({ name }) => name === '@astrojs/sitemap'
          );
    
          if (!userSitemap) {
            // If sitemap wasn’t found, add it.
            updateConfig({
              integrations: [sitemap({ /* opts */ }],
            });
          }
        },
      };
    };
  • #8696 2167ffd72 Thanks @matthewp! - View transitions can now be triggered from JavaScript!

    Import the client-side router from "astro:transitions/client" and enjoy your new remote control for navigation:

    import { navigate } from 'astro:transitions/client';
    
    // Navigate to the selected option automatically.
    document.querySelector('select').onchange = (ev) => {
      let href = ev.target.value;
      navigate(href);
    };
  • #8696 2167ffd72 Thanks @matthewp! - Route Announcer in <ViewTransitions />

    The View Transitions router now does route announcement. When transitioning between pages with a traditional MPA approach, assistive technologies will announce the page title when the page finishes loading. This does not automatically happen during client-side routing, so visitors relying on these technologies to announce routes are not aware when a page has changed.

    The view transitions route announcer runs after the astro:page-load event, looking for the page <title> to announce. If one cannot be found, the announcer falls back to the first <h1> it finds, or otherwise announces the pathname. We recommend you always include a <title> in each page for accessibility.

    See the View Transitions docs for more on how accessibility is handled.

Patch Changes

Don't miss a new astro release

NewReleases is sending notifications on new releases.