astro

The web framework for content-driven websites. ⭐️ Star to support our work!

OTHER License

Downloads
8.9M
Stars
43K
Committers
807

Bot releases are visible (Hide)

astro - [email protected]

Published by astrobot-houston about 2 months 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

astro - [email protected]

Published by astrobot-houston about 2 months ago

Patch Changes

astro - [email protected]

Published by astrobot-houston about 2 months ago

Minor Changes

  • #11729 1c54e63 Thanks @ematipico! - Adds a new variant sync for the astro:config:setup hook's command property. This value is set when calling the command astro sync.

    If your integration previously relied on knowing how many variants existed for the command property, you must update your logic to account for this new option.

  • #11743 cce0894 Thanks @ph1p! - Adds a new, optional property timeout for the client:idle directive.

    This value allows you to specify a maximum time to wait, in milliseconds, before hydrating a UI framework component, even if the page is not yet done with its initial load. This means you can delay hydration for lower-priority UI elements with more control to ensure your element is interactive within a specified time frame.

    <ShowHideButton client:idle={{ timeout: 500 }} />
    
  • #11677 cb356a5 Thanks @ematipico! - Adds a new option fallbackType to i18n.routing configuration that allows you to control how fallback pages are handled.

    When i18n.fallback is configured, this new routing option controls whether to redirect to the fallback page, or to rewrite the fallback page's content in place.

    The "redirect" option is the default value and matches the current behavior of the existing fallback system.

    The option "rewrite" uses the new rewriting system to create fallback pages that render content on the original, requested URL without a browser refresh.

    For example, the following configuration will generate a page /fr/index.html that will contain the same HTML rendered by the page /en/index.html when src/pages/fr/index.astro does not exist.

    // astro.config.mjs
    export default defineConfig({
      i18n: {
        locals: ['en', 'fr'],
        defaultLocale: 'en',
        routing: {
          prefixDefaultLocale: true,
          fallbackType: 'rewrite',
        },
        fallback: {
          fr: 'en',
        },
      },
    });
    
  • #11708 62b0d20 Thanks @martrapp! - Adds a new object swapFunctions to expose the necessary utility functions on astro:transitions/client that allow you to build custom swap functions to be used with view transitions.

    The example below uses these functions to replace Astro's built-in default swap function with one that only swaps the <main> part of the page:

    <script>
      import { swapFunctions } from 'astro:transitions/client';
    
      document.addEventListener('astro:before-swap', (e) => { e.swap = () => swapMainOnly(e.newDocument) });
    
      function swapMainOnly(doc: Document) {
        swapFunctions.deselectScripts(doc);
        swapFunctions.swapRootAttributes(doc);
        swapFunctions.swapHeadElements(doc);
        const restoreFocusFunction = swapFunctions.saveFocus();
        const newMain = doc.querySelector('main');
        const oldMain = document.querySelector('main');
        if (newMain && oldMain) {
          swapFunctions.swapBodyElement(newMain, oldMain);
        } else {
          swapFunctions.swapBodyElement(doc.body, document.body);
        }
        restoreFocusFunction();
      };
    </script>
    

    See the view transitions guide for more information about hooking into the astro:before-swap lifecycle event and adding a custom swap implementation.

  • #11843 5b4070e Thanks @bholmesdev! - Exposes z from the new astro:schema module. This is the new recommended import source for all Zod utilities when using Astro Actions.

    Migration for Astro Actions users

    z will no longer be exposed from astro:actions. To use z in your actions, import it from astro:schema instead:

    import {
      defineAction,
    -  z,
    } from 'astro:actions';
    + import { z } from 'astro:schema';
    
  • #11843 5b4070e Thanks @bholmesdev! - The Astro Actions API introduced behind a flag in v4.8.0 is no longer experimental and is available for general use.

    Astro Actions allow you to define and call backend functions with type-safety, performing data fetching, JSON parsing, and input validation for you.

    Actions can be called from client-side components and HTML forms. This gives you to flexibility to build apps using any technology: React, Svelte, HTMX, or just plain Astro components. This example calls a newsletter action and renders the result using an Astro component:

    ---
    // src/pages/newsletter.astro
    import { actions } from 'astro:actions';
    const result = Astro.getActionResult(actions.newsletter);
    ---
    
    {result && !result.error && <p>Thanks for signing up!</p>}
    <form method="POST" action={actions.newsletter}>
      <input type="email" name="email" />
      <button>Sign up</button>
    </form>
    

    If you were previously using this feature, please remove the experimental flag from your Astro config:

    import { defineConfig } from 'astro'
    
    export default defineConfig({
    -  experimental: {
    -    actions: true,
    -  }
    })
    

    If you have been waiting for stabilization before using Actions, you can now do so.

    For more information and usage examples, see our brand new Actions guide.

Patch Changes

  • #11677 cb356a5 Thanks @ematipico! - Fixes a bug in the logic of Astro.rewrite() which led to the value for base, if configured, being automatically prepended to the rewrite URL passed. This was unintended behavior and has been corrected, and Astro now processes the URLs exactly as passed.

    If you use the rewrite() function on a project that has base configured, you must now prepend the base to your existing rewrite URL:

    // astro.config.mjs
    export default defineConfig({
      base: '/blog',
    });
    
    // src/middleware.js
    export function onRequest(ctx, next) {
    -  return ctx.rewrite("/about")
    +  return ctx.rewrite("/blog/about")
    }
    
  • #11862 0e35afe Thanks @ascorbic! - BREAKING CHANGE to experimental content layer loaders only!

    Passes AstroConfig instead of AstroSettings object to content layer loaders.

    This will not affect you unless you have created a loader that uses the settings object. If you have, you will need to update your loader to use the config object instead.

    export default function myLoader() {
      return {
        name: 'my-loader'
    -   async load({ settings }) {
    -     const base = settings.config.base;
    +   async load({ config }) {
    +     const base = config.base;
          // ...
        }
      }
    }
    
    

    Other properties of the settings object are private internals, and should not be accessed directly. If you think you need access to other properties, please open an issue to discuss your use case.

  • #11772 6272e6c Thanks @bluwy! - Uses magicast to update the config for astro add

  • #11845 440a4be Thanks @bluwy! - Replaces execa with tinyexec internally

  • #11858 8bab233 Thanks @ascorbic! - Correctly resolves content layer images when filePath is not set

astro - @astrojs/[email protected]

Published by astrobot-houston about 2 months ago

Patch Changes

astro - @astrojs/[email protected]

Published by astrobot-houston about 2 months ago

Minor Changes

  • #11385 d6611e8 Thanks @Fryuni! - Adds support for connecting Astro DB to any remote LibSQL server. This allows Astro DB to be used with self-hosting and air-gapped deployments.

    To connect Astro DB to a remote LibSQL server instead of Studio, set the following environment variables:

    • ASTRO_DB_REMOTE_URL: the connection URL to your LibSQL server
    • ASTRO_DB_APP_TOKEN: the auth token to your LibSQL server

    Details of the LibSQL connection can be configured using the connection URL. For example, memory:?syncUrl=libsql%3A%2F%2Fdb-server.example.com would create an in-memory embedded replica for the LibSQL DB on libsql://db-server.example.com.

    For more details, please visit the Astro DB documentation

Patch Changes

astro - [email protected]

Published by astrobot-houston about 2 months ago

Patch Changes

astro - @astrojs/[email protected]

Published by astrobot-houston about 2 months ago

Patch Changes

  • #11818 88ef1d0 Thanks @bluwy! - Fixes CSS in the layout component to be ordered first before any other components in the MDX file
astro - @astrojs/[email protected]

Published by astrobot-houston about 2 months ago

Patch Changes

  • #11834 5f2536b Thanks @ph1p! - Preact signals are now serialized correctly in arrays when they are given to components.
astro - @astrojs/[email protected]

Published by astrobot-houston about 2 months ago

Patch Changes

  • #11846 ed7bbd9 Thanks @HiDeoo! - Fixes an issue preventing to use Astro components as Markdoc tags and nodes when configured using the extends property.
astro - @astrojs/[email protected]

Published by astrobot-houston about 2 months ago

Patch Changes

  • #11829 f1df1b3 Thanks @oosawy! - Prevent Partytown integration from inserting a 'null' string into the body
astro - [email protected]

Published by astrobot-houston about 2 months ago

Major Changes

  • #11798 e9e2139 Thanks @matthewp! - Unflag globalRoutePriority

    The previously experimental feature globalRoutePriority is now the default in Astro 5.

    This was a refactoring of route prioritization in Astro, making it so that injected routes, file-based routes, and redirects are all prioritized using the same logic. This feature has been enabled for all Starlight projects since it was added and should not affect most users.

  • #11679 ea71b90 Thanks @florian-lefebvre! - The astro:env feature introduced behind a flag in v4.10.0 is no longer experimental and is available for general use. If you have been waiting for stabilization before using astro:env, you can now do so.

    This feature lets you configure a type-safe schema for your environment variables, and indicate whether they should be available on the server or the client.

    To configure a schema, add the env option to your Astro config and define your client and server variables. If you were previously using this feature, please remove the experimental flag from your Astro config and move your entire env configuration unchanged to a top-level option.

    import { defineConfig, envField } from 'astro/config';
    
    export default defineConfig({
      env: {
        schema: {
          API_URL: envField.string({ context: 'client', access: 'public', optional: true }),
          PORT: envField.number({ context: 'server', access: 'public', default: 4321 }),
          API_SECRET: envField.string({ context: 'server', access: 'secret' }),
        },
      },
    });
    

    You can import and use your defined variables from the appropriate /client or /server module:

    ---
    import { API_URL } from 'astro:env/client';
    import { API_SECRET_TOKEN } from 'astro:env/server';
    
    const data = await fetch(`${API_URL}/users`, {
      method: 'GET',
      headers: {
        'Content-Type': 'application/json',
        Authorization: `Bearer ${API_SECRET_TOKEN}`,
      },
    });
    ---
    
    <script>
      import { API_URL } from 'astro:env/client';
    
      fetch(`${API_URL}/ping`);
    </script>
    
  • #11788 7c0ccfc Thanks @ematipico! - Updates the default value of security.checkOrigin to true, which enables Cross-Site Request Forgery (CSRF) protection by default for pages rendered on demand.

    If you had previously configured security.checkOrigin: true, you no longer need this set in your Astro config. This is now the default and it is safe to remove.

    To disable this behavior and opt out of automatically checking that the “origin” header matches the URL sent by each request, you must explicitly set security.checkOrigin: false:

    export default defineConfig({
    +  security: {
    +    checkOrigin: false
    +  }
    })
    
  • #11741 6617491 Thanks @bluwy! - Removes internal JSX handling and moves the responsibility to the @astrojs/mdx package directly. The following exports are also now removed:

    • astro/jsx/babel.js
    • astro/jsx/component.js
    • astro/jsx/index.js
    • astro/jsx/renderer.js
    • astro/jsx/server.js
    • astro/jsx/transform-options.js

    If your project includes .mdx files, you must upgrade @astrojs/mdx to the latest version so that it doesn't rely on these entrypoints to handle your JSX.

  • #11782 9a2aaa0 Thanks @Princesseuh! - Makes the compiledContent property of Markdown content an async function, this change should fix underlying issues where sometimes when using a custom image service and images inside Markdown, Node would exit suddenly without any error message.

    ---
    import * as myPost from "../post.md";
    
    - const content = myPost.compiledContent();
    + const content = await myPost.compiledContent();
    ---
    
    <Fragment set:html={content} />
    
  • #11770 cfa6a47 Thanks @Princesseuh! - Removed support for the Squoosh image service. As the underlying library libsquoosh is no longer maintained, and the image service sees very little usage we have decided to remove it from Astro.

    Our recommendation is to use the base Sharp image service, which is more powerful, faster, and more actively maintained.

    - import { squooshImageService } from "astro/config";
    import { defineConfig } from "astro/config";
    
    export default defineConfig({
    -  image: {
    -    service: squooshImageService()
    -  }
    });
    

    If you are using this service, and cannot migrate to the base Sharp image service, a third-party extraction of the previous service is available here: https://github.com/Princesseuh/astro-image-service-squoosh

Patch Changes

  • #11780 c6622ad Thanks @Princesseuh! - Deprecates the Squoosh image service, to be removed in Astro 5.0. We recommend migrating to the default Sharp service.

  • #11732 4cd6c43 Thanks @matthewp! - Use GET requests with preloading for Server Islands

    Server Island requests include the props used to render the island as well as any slots passed in (excluding the fallback slot). Since browsers have a max 4mb URL length we default to using a POST request to avoid overflowing this length.

    However in reality most usage of Server Islands are fairly isolated and won't exceed this limit, so a GET request is possible by passing this same information via search parameters.

    Using GET means we can also include a <link rel="preload"> tag to speed up the request.

    This change implements this, with safe fallback to POST.

  • #11773 86a3391 Thanks @ematipico! - Changes messages logged when using unsupported, deprecated, or experimental adapter features for clarity

  • #11774 c6400ab Thanks @florian-lefebvre! - Fixes the path returned by injectTypes

  • #11771 49650a4 Thanks @florian-lefebvre! - Fixes an error thrown by astro sync when an astro:env virtual module is imported inside the Content Collections config

  • #11744 b677429 Thanks @bluwy! - Disables the WebSocket server when creating a Vite server for loading config files

astro - @astrojs/[email protected]

Published by astrobot-houston about 2 months ago

Major Changes

  • #11679 ea71b90 Thanks @florian-lefebvre! - Adds stable support for astro:env

  • #11770 cfa6a47 Thanks @Princesseuh! - Removed support for the Squoosh image service. As the underlying library libsquoosh is no longer maintained, and the image service sees very little usage we have decided to remove it from Astro.

    Our recommendation is to use the base Sharp image service, which is more powerful, faster, and more actively maintained.

    - import { squooshImageService } from "astro/config";
    import { defineConfig } from "astro/config";
    
    export default defineConfig({
    -  image: {
    -    service: squooshImageService()
    -  }
    });
    

    If you are using this service, and cannot migrate to the base Sharp image service, a third-party extraction of the previous service is available here: https://github.com/Princesseuh/astro-image-service-squoosh

Patch Changes

  • #11783 fc81b01 Thanks @matthewp! - Prevent race condition with Node 18

    Using Node 18 there can be a race condition where polyfill for the crypto global is not applied in time. This change ensures the polyfills run first.

astro - @astrojs/[email protected]

Published by astrobot-houston about 2 months ago

Patch Changes

astro - @astrojs/[email protected]

Published by astrobot-houston about 2 months ago

Patch Changes

astro - @astrojs/[email protected]

Published by astrobot-houston about 2 months ago

Major Changes

  • #11679 ea71b90 Thanks @florian-lefebvre! - Adds stable support for astro:env

  • #11770 cfa6a47 Thanks @Princesseuh! - Removed support for the Squoosh image service. As the underlying library libsquoosh is no longer maintained, and the image service sees very little usage we have decided to remove it from Astro.

    Our recommendation is to use the base Sharp image service, which is more powerful, faster, and more actively maintained.

    - import { squooshImageService } from "astro/config";
    import { defineConfig } from "astro/config";
    
    export default defineConfig({
    -  image: {
    -    service: squooshImageService()
    -  }
    });
    

    If you are using this service, and cannot migrate to the base Sharp image service, a third-party extraction of the previous service is available here: https://github.com/Princesseuh/astro-image-service-squoosh

astro - @astrojs/[email protected]

Published by astrobot-houston about 2 months ago

Minor Changes

  • #11741 6617491 Thanks @bluwy! - Updates adapter server entrypoint to use @astrojs/mdx/server.js

    This is an internal change. Handling JSX in your .mdx files has been moved from Astro internals and is now the responsibility of this integration. You should not notice a change in your project, and no update to your code is required.

astro - [email protected] Latest Release

Published by astrobot-houston about 2 months ago

Patch Changes

  • #11809 62e97a2 Thanks @bholmesdev! - Fixes usage of .transform(), .refine(), .passthrough(), and other effects on Action form inputs.

  • #11812 260c4be Thanks @bholmesdev! - Exposes ActionAPIContext type from the astro:actions module.

  • #11813 3f7630a Thanks @bholmesdev! - Fixes unexpected undefined value when calling an action from the client without a return value.

astro - [email protected]

Published by astrobot-houston 2 months ago

Patch Changes

  • #11794 3691a62 Thanks @bholmesdev! - Fixes unexpected warning log when using Actions on "hybrid" rendered projects.

  • #11801 9f943c1 Thanks @delucis! - Fixes a bug where the filePath property was not available on content collection entries when using the content layer file() loader with a JSON file that contained an object instead of an array. This was breaking use of the image() schema utility among other things.

astro - [email protected]

Published by astrobot-houston 2 months ago

Patch Changes

astro - @astrojs/[email protected]

Published by astrobot-houston 2 months ago

Minor Changes

  • #11728 5ea02b1 Thanks @matthewp! - Deprecates the functionPerRoute option

    This option is now deprecated, and will be removed entirely in Astro v5.0. We suggest removing this option from your configuration as soon as you are able to:

    import { defineConfig } from 'astro/config';
    import vercel from '@astrojs/vercel/serverless';
    
    export default defineConfig({
      // ...
      output: 'server',
      adapter: vercel({
    -     functionPerRoute: true,
      }),
    });
    

Patch Changes

  • #11783 fc81b01 Thanks @matthewp! - Prevent race condition with Node 18

    Using Node 18 there can be a race condition where polyfill for the crypto global is not applied in time. This change ensures the polyfills run first.

Package Rankings
Top 0.43% on Npmjs.org
Top 8.17% on Proxy.golang.org
Badges
Extracted from project README
CI License npm version astro version create-astro version @astrojs/react version @astrojs/preact version @astrojs/solid version @astrojs/svelte version @astrojs/vue version @astrojs/lit version @astrojs/node version @astrojs/vercel version @astrojs/cloudflare version @astrojs/partytown version @astrojs/sitemap version @astrojs/tailwind version @astrojs/alpinejs version @astrojs/mdx version @astrojs/db version @astrojs/rss version @astrojs/netlify version CII Best Practices Astro's sponsors.