Skip to content

Latest commit

 

History

History
2940 lines (1756 loc) · 206 KB

CHANGELOG.md

File metadata and controls

2940 lines (1756 loc) · 206 KB

astro

2.5.4

Patch Changes

2.5.3

Patch Changes

  • #6758 f558a9e20 Thanks @bholmesdev! - Improve style and script handling across content collection files. This addresses style bleed present in @astrojs/markdoc v0.1.0

  • #7143 b41963b77 Thanks @johannesspohr! - Render 404 page content when a Response with status 404 is returned from a page

2.5.2

Patch Changes

2.5.1

Patch Changes

2.5.0

Minor Changes

  • #7071 e186ecc5e Thanks @johannesspohr! - Render sibling components in parallel

  • #6850 c6d7ebefd Thanks @bholmesdev! - Content collections now support data formats including JSON and YAML. You can also create relationships, or references, between collections to pull information from one collection entry into another. Learn more on our updated Content Collections docs.

  • #6991 719002ca5 Thanks @MoustaphaDev! - Enable experimental support for hybrid SSR with pre-rendering enabled by default

    astro.config.mjs

    import { defineConfig } from 'astro/config';
    export defaultdefineConfig({
       output: 'hybrid',
           experimental: {
           hybridOutput: true,
       },
    })

    Then add export const prerender = false to any page or endpoint you want to opt-out of pre-rendering.

    src/pages/contact.astro

    ---
    export const prerender = false;
    
    if (Astro.request.method === 'POST') {
      // handle form submission
    }
    ---
    
    <form method="POST">
      <input type="text" name="name" />
      <input type="email" name="email" />
      <button type="submit">Submit</button>
    </form>
  • #7074 73ec6f6c1 Thanks @bluwy! - Integrations can add new client: directives through the astro:config:setup hook's addClientDirective() API. To enable this API, the user needs to set experimental.customClientDirectives to true in their config.

    import { defineConfig } from 'astro/config';
    import onClickDirective from 'astro-click-directive';
    
    export default defineConfig({
      integrations: [onClickDirective()],
      experimental: {
        customClientDirectives: true,
      },
    });
    export default function onClickDirective() {
      return {
        hooks: {
          'astro:config:setup': ({ addClientDirective }) => {
            addClientDirective({
              name: 'click',
              entrypoint: 'astro-click-directive/click.js',
            });
          },
        },
      };
    }
    <Counter client:click />

    The client directive file (e.g. astro-click-directive/click.js) should export a function of type ClientDirective:

    import type { ClientDirective } from 'astro';
    
    const clickDirective: ClientDirective = (load, opts, el) => {
      window.addEventListener(
        'click',
        async () => {
          const hydrate = await load();
          await hydrate();
        },
        { once: true }
      );
    };
    
    export default clickDirective;
  • #6706 763ff2d1e Thanks @wulinsheng123! - Adds an opt-in way to minify the HTML output.

    Using the compressHTML option Astro will remove whitespace from Astro components. This only applies to components written in .astro format and happens in the compiler to maximize performance. You can enable with:

    import { defineConfig } from 'astro/config';
    
    export default defineConfig({
      compressHTML: true,
    });

    Compression occurs both in development mode and in the final build.

  • #7069 c1669c001 Thanks @Princesseuh! - Added Polymorphic type helper to astro/types to easily create polymorphic components:

    ---
    import { HTMLTag, Polymorphic } from 'astro/types';
    
    type Props<Tag extends HTMLTag> = Polymorphic<{ as: Tag }>;
    
    const { as: Tag, ...props } = Astro.props;
    ---
    
    <Tag {...props} />
  • #7093 3d525efc9 Thanks @matthewp! - Prevent removal of nested slots within islands

    This change introduces a new flag that renderers can add called supportsAstroStaticSlot. What this does is let Astro know that the render is sending <astro-static-slot> as placeholder values for static (non-hydrated) slots which Astro will then remove.

    This change is completely backwards compatible, but fixes bugs caused by combining ssr-only and client-side framework components like so:

    <Component>
      <div>
        <Component client:load>
          <span>Nested</span>
        </Component>
      </div>
    </Component>

Patch Changes

2.4.5

Patch Changes

2.4.4

Patch Changes

  • #7047 48395c815 Thanks @Princesseuh! - Fix /_image endpoint not being prefixed with the base path in build SSR

  • #6916 630f8c8ef Thanks @bholmesdev! - Add fast lookups for content collection entries when using getEntryBySlug(). This generates a lookup map to ensure O(1) retrieval.

2.4.3

Patch Changes

2.4.2

Patch Changes

  • #7009 1d4db68e6 Thanks @Princesseuh! - Fix types from astro/client not working properly due to client-base.d.ts being an non-ambient declaration file

  • #7010 e9f0dd9b4 Thanks @ematipico! - Call next() without return anything should work, with a warning

2.4.1

Patch Changes

  • #6995 71332cf96 Thanks @Princesseuh! - Move sharpImageService and squooshImageService functions to astro/config so they can be imported

2.4.0

Minor Changes

  • #6990 818252acd Thanks @Princesseuh! - Generated optimized images are now cached inside the node_modules/.astro/assets folder. The cached images will be used to avoid doing extra work and speed up subsequent builds.

  • #6659 80e3d4d3d Thanks @lilnasy! - Implement Inline Stylesheets RFC as experimental

  • #6771 3326492b9 Thanks @matthewp! - Implements a new class-based scoping strategy

    This implements the Scoping RFC, providing a way to opt in to increased style specificity for Astro component styles.

    This prevents bugs where global styles override Astro component styles due to CSS ordering and the use of element selectors.

    To enable class-based scoping, you can set it in your config:

    import { defineConfig } from 'astro/config';
    
    export default defineConfig({
      scopedStyleStrategy: 'class',
    });

    Note that the 0-specificity :where pseudo-selector is still the default strategy. The intent is to change 'class' to be the default in 3.0.

  • #6959 cac4a321e Thanks @bluwy! - Support <Code inline /> to output inline code HTML (no pre tag)

  • #6721 831b67cdb Thanks @ematipico! - Implements a new experimental middleware in Astro.

    The middleware is available under the following experimental flag:

    export default defineConfig({
      experimental: {
        middleware: true,
      },
    });

    Or via CLI, using the new argument --experimental-middleware.

    Create a file called middleware.{js,ts} inside the src folder, and export a onRequest function.

    From astro/middleware, use the defineMiddleware utility to take advantage of type-safety, and use the sequence utility to chain multiple middleware functions.

    Example:

    import { defineMiddleware, sequence } from 'astro/middleware';
    
    const redirects = defineMiddleware((context, next) => {
      if (context.request.url.endsWith('/old-url')) {
        return context.redirect('/new-url');
      }
      return next();
    });
    
    const minify = defineMiddleware(async (context, next) => {
      const repsonse = await next();
      const minifiedHtml = await minifyHtml(response.text());
      return new Response(minifiedHtml, {
        status: 200,
        headers: response.headers,
      });
    });
    
    export const onRequest = sequence(redirects, minify);
  • #6932 49514e4ce Thanks @bluwy! - Upgrade shiki to v0.14.1. This updates the shiki theme colors and adds the theme name to the pre tag, e.g. <pre class="astro-code github-dark">.

Patch Changes

  • #6973 0883fd487 Thanks @matthewp! - Ensure multiple cookies set in dev result in multiple set-cookie headers

  • Updated dependencies [49514e4ce]:

    • @astrojs/markdown-remark@2.2.0

2.3.4

Patch Changes

  • #6967 a8a319aef Thanks @bluwy! - Fix astro-entry error on build with multiple JSX frameworks

  • #6961 a695e44ae Thanks @Princesseuh! - Fix getImage type

  • #6956 367e61776 Thanks @lilnasy! - Changed where various parts of the build pipeline look to decide if a page should be prerendered. They now exclusively consider PageBuildData, allowing integrations to participate in the decision.

  • #6969 77270cc2c Thanks @bluwy! - Avoid removing leading slash for build.assetsPrefix value in the build output

  • #6910 895fa07d8 Thanks @natemoo-re! - Inline process.env boolean values (0, 1, true, false) during the build. This helps with DCE and allows for better export const prerender detection.

  • #6958 72c6bf01f Thanks @bluwy! - Fix content render imports flow

  • #6952 e5bd084c0 Thanks @Princesseuh! - Update allowed Sharp versions to support 0.32.0

2.3.3

Patch Changes

  • #6940 a98df9374 Thanks @delucis! - Support custom 404s added via injectRoute or as src/pages/404.html

  • #6948 50975f2ea Thanks @imchell! - Placeholders for slots are cleaned in HTML String that is rendered

  • #6848 ebae1eaf8 Thanks @Princesseuh! - Update experimental.assets's image.service configuration to allow for a config option in addition to an entrypoint

  • #6953 dc062f669 Thanks @Princesseuh! - Update astro check to use version 1.0.0 of the Astro language server

  • Updated dependencies [ac57b5549]:

    • @astrojs/telemetry@2.1.1
    • @astrojs/webapi@2.1.1

2.3.2

Patch Changes

2.3.1

Patch Changes

  • #6859 4c7ba4da0 Thanks @andremralves! - Fix Astro.params does not contain path parameter from URL with non-English characters.

  • #6872 b6154d2d5 Thanks @bluwy! - Fix hoisted scripts path for linked package Astro components

  • #6862 1f2699461 Thanks @jcdogo! - Fixes bug with assetsPrefix not being prepended to component-url and renderer-url in astro islands when using SSR mode.

  • #6877 edabf01b4 Thanks @bluwy! - Upgrade to Vite 4.3

  • #6902 0afff3274 Thanks @bluwy! - Disable Vite optimizer for sync and config loading. Improve first page load time for warm server startup.

2.3.0

Minor Changes

Patch Changes

  • #6544 a9c22994e Thanks @wulinsheng123! - Correctly generate directories for assets when users customise the output via rollup options.

  • #6825 948a6d7be Thanks @Princesseuh! - Fix unnecessary warning when using images inside the src/content folder with experimental.assets

  • Updated dependencies [2511d58d5]:

    • @astrojs/markdown-remark@2.1.4

2.2.3

Patch Changes

2.2.2

Patch Changes

2.2.1

Patch Changes

2.2.0

Minor Changes

  • #6703 a1108e037 Thanks @Princesseuh! - Move image() to come from schema instead to fix it not working with refine and inside complex types

    Migration:

    Remove the image import from astro:content, and instead use a function to generate your schema, like such:

    import { defineCollection, z } from 'astro:content';
    
    defineCollection({
      schema: ({ image }) =>
        z.object({
          image: image().refine((img) => img.width >= 200, {
            message: 'image too small',
          }),
        }),
    });
  • #6714 ff0430786 Thanks @bluwy! - Add build.assetsPrefix option for CDN support. If set, all Astro-generated asset links will be prefixed with it. For example, setting it to https://cdn.example.com would generate https://cdn.example.com/_astro/penguin.123456.png links.

    Also adds import.meta.env.ASSETS_PREFIX environment variable that can be used to manually create asset links not handled by Astro.

Patch Changes

  • #6753 489dd8d69 Thanks @bluwy! - Fix getViteConfig return type

  • #6744 a1a4f45b5 Thanks @Princesseuh! - Fix remote images in Markdown throwing errors when using experimental.assets

  • #6762 8b88e4cf1 Thanks @Princesseuh! - Improved error message when an error was encountered while generating types

  • #6719 d54cbe413 Thanks @matthewp! - Better errors for when response is already sent

    This adds clearer error messaging when a Response has already been sent to the browser and the developer attempts to use:

    • Astro.cookies.set
    • Astro.redirect
  • #6741 4c347ab51 Thanks @Princesseuh! - Fix content-type header being wrong in dev on images from astro:assets

  • #6739 2f2e572e9 Thanks @Princesseuh! - Added more types and utilities exports related to astro:assets to help building custom image components and image services

  • #6759 7116c021a Thanks @bluwy! - Upgrade to Vite 4.2

  • Updated dependencies [a1a4f45b5]:

    • @astrojs/markdown-remark@2.1.3

2.1.9

Patch Changes

2.1.8

Patch Changes

  • #6675 1f783e320 Thanks @matthewp! - Prevent frontmatter errors from crashing the dev server

  • #6688 2e92e9aa9 Thanks @JohannesKlauss! - Add a additional check for null on the req.body check in NodeApp.render.

  • #6578 adecda7d6 Thanks @wulinsheng123! - add new flag with open for dev and preview

  • #6680 386336441 Thanks @koriwi! - Invalidates cache when changing serviceEntryPoint

  • #6653 7c439868a Thanks @bholmesdev! - Simplify Markdoc configuration with a new markdoc.config.mjs file. This lets you import Astro components directly to render as Markdoc tags and nodes, without the need for the previous components property. This new configuration also unlocks passing variables to your Markdoc from the Content component (see the new docs).

    Migration

    Move any existing Markdoc config from your astro.config to a new markdoc.config.mjs file at the root of your project. This should be applied as a default export, with the optional defineMarkdocConfig() helper for autocomplete in your editor.

    This example configures an aside Markdoc tag. Note that components should be imported and applied to the render attribute directly, instead of passing the name as a string:

    // markdoc.config.mjs
    import { defineMarkdocConfig } from '@astrojs/markdoc/config';
    import Aside from './src/components/Aside.astro';
    
    export default defineMarkdocConfig({
      tags: {
        aside: {
          render: Aside,
        },
      },
    });

    You should also remove the components prop from your Content components. Since components are imported into your config directly, this is no longer needed.

    ---
    - import Aside from '../components/Aside.astro';
    import { getEntryBySlug } from 'astro:content';
    
    const entry = await getEntryBySlug('docs', 'why-markdoc');
    const { Content } = await entry.render();
    ---
    
    <Content
    - components={{ Aside }}
    />
  • #6639 25cd3e574 Thanks @tony-sull! - Fixes an attribute naming mismatch in the definition for elements in astro.JSX

  • #6353 4bf87c64f Thanks @wulinsheng123! - Throw better error when a dynamic endpoint without additional extensions is prerendered with undefined params.

  • #6643 fc0ed9c53 Thanks @Princesseuh! - Fix images not having the proper path when using base

2.1.7

Patch Changes

  • #6192 b7194103e Thanks @erg208! - Updated to fix the Node SSR fails on POST with Express JSON middleware

  • #6630 cfcf2e2ff Thanks @bholmesdev! - Support automatic image optimization for Markdoc images when using experimental.assets. You can follow our Assets guide to enable this feature in your project. Then, start using relative or aliased image sources in your Markdoc files for automatic optimization:

    <!--Relative paths-->
    
    ![The Milky Way Galaxy](../assets/galaxy.jpg)
    
    <!--Or configured aliases-->
    
    ![Houston smiling and looking cute](~/assets/houston-smiling.jpg)
  • #6647 45da39a86 Thanks @bluwy! - Fix --mode flag for builds

  • #6638 7daef9a29 Thanks @matthewp! - Avoid implicit head injection when a head is in the tree

2.1.6

Patch Changes

  • #6633 9caf2a9cc Thanks @bholmesdev! - Fix failed astro sync call when running astro check. This change also reverts alias support in CSS styles.

  • #6627 d338b6f74 Thanks @Princesseuh! - Update frontmatter assets to be relative to the current file instead of src/assets

2.1.5

Patch Changes

  • #6604 7f7a8504b Thanks @Princesseuh! - Fix using optimized images in Markdown not working

  • #6617 38e6ec21e Thanks @MoustaphaDev! - Fix tsconfig alias regression

  • #6588 f42f47dc6 Thanks @bholmesdev! - Allow access to content collection entry information (including parsed frontmatter and the entry slug) from your Markdoc using the $entry variable:

    ---
    title: Hello Markdoc!
    ---
    
    # {% $entry.data.title %}
  • Updated dependencies [7f7a8504b]:

    • @astrojs/markdown-remark@2.1.2

2.1.4

Patch Changes

2.1.3

Patch Changes

  • #6530 acf78c5e2 Thanks @Princesseuh! - Fix various inaccuracies with types related to the new Assets features:

    • getConfiguredImageService wasn't present on the astro:assets types.
    • ImageMetadata wasn't exported
    • Fixed wrong module declaration for avif, heic and heif files.
    • Add missing module declaration for SVGs imports
  • #6527 04e624d06 Thanks @bluwy! - Treeshake exported client components that are not imported

  • #6533 cc90d7219 Thanks @Princesseuh! - Added a warning when trying to use experimental.assets with a not compatible adapter

  • #6483 a9a6ae298 Thanks @Princesseuh! - Fix images defined in content collections schemas not working

  • #6537 6a7cf0712 Thanks @matthewp! - Prevent astro:content from depending on Node builtins

  • #6488 bfd67ea74 Thanks @matthewp! - Remove use of createRequire breaking non-Node hosts.

  • #6503 f6eddffa0 Thanks @bholmesdev! - Add caching to getCollection() queries for faster SSG production builds

  • #6508 c63874090 Thanks @bholmesdev! - Improve content collection error formatting:

    • Bold the collection and entry that failed
    • Consistently list the frontmatter key at the start of every error
    • Rich errors for union types
  • #6485 d637d1ea5 Thanks @bluwy! - Fix @astrojs/prism edgecase with strict package managers

  • #6532 637f9bc72 Thanks @Princesseuh! - Fix env.d.ts changing types wrongly on every restart when experimental.assets is enabled

  • #6460 77a046e88 Thanks @bluwy! - Add default .npmrc file when adding the Lit integration through astro add lit and using pnpm.

2.1.2

Patch Changes

2.1.1

Patch Changes

2.1.0

Minor Changes

  • #6150 b087b83fe Thanks @morellodev! - Add getStaticPaths type helpers to infer params and props

  • #6344 694918a56 Thanks @Princesseuh! - Add a new experimental flag (experimental.assets) to enable our new core Assets story.

    This unlocks a few features:

    • A new built-in image component and JavaScript API to transform and optimize images.
    • Relative images with automatic optimization in Markdown.
    • Support for validating assets using content collections.
    • and more!

    See Assets (Experimental) on our docs site for more information on how to use this feature!

  • #6435 a20610609 Thanks @matthewp! - Expose the manifest to plugins via the astro:ssr-manifest virtual module

  • #6394 a4a74ab70 Thanks @ematipico! - Add --help to various commands: check, sync, dev, preview, and build

  • #6356 75921b3cd Thanks @ematipico! - Added a new --watch flag to the command astro check

  • #6213 afbbc4d5b Thanks @Princesseuh! - Updated compilation settings to disable downlevelling for Node 14

Patch Changes

  • #6209 fec583909 Thanks @bholmesdev! - Introduce the (experimental) @astrojs/markdoc integration. This unlocks Markdoc inside your Content Collections, bringing support for Astro and UI components in your content. This also improves Astro core internals to make Content Collections extensible to more file types in the future.

    You can install this integration using the astro add command:

    astro add markdoc
    

    Read the @astrojs/markdoc documentation for usage instructions, and browse the new with-markdoc starter to try for yourself.

  • Updated dependencies [694918a56, afbbc4d5b]:

    • @astrojs/markdown-remark@2.1.0
    • @astrojs/telemetry@2.1.0
    • @astrojs/webapi@2.1.0

2.0.18

Patch Changes

2.0.17

Patch Changes

2.0.16

Patch Changes

  • #6363 d94aae776 Thanks @matthewp! - Fixes cases where head is injected in body when using Astro.slots.render()

  • Updated dependencies [5aa6580f7]:

    • @astrojs/webapi@2.0.2
    • @astrojs/telemetry@2.0.1

2.0.15

Patch Changes

2.0.14

Patch Changes

  • #6277 d9474d467 Thanks @bluwy! - Bump Vite to 4.1

  • #6268 933c651fb Thanks @natemoo-re! - Do not transform --camelCase custom properties to --camel-case when they're in a style attribute.

    This bug fix is backwards-compatible because we will emit both --camelCase and --camel-case temporarily. This behavior will be removed in a future version of Astro.

  • Updated dependencies [bb1801013]:

    • @astrojs/webapi@2.0.1

2.0.13

Patch Changes

2.0.12

Patch Changes

2.0.11

Patch Changes

2.0.10

Patch Changes

2.0.9

Patch Changes

2.0.8

Patch Changes

2.0.7

Patch Changes

  • #6161 f6fc662c3 Thanks @matthewp! - Prevent ?inline and ?raw CSS from being bundled as CSS

  • #6149 592386b75 Thanks @bloycey! - Moved pagination error to AstroErrorData

  • #6153 1b591a143 Thanks @torchsmith! - Respect vite.build.emptyOutDir setting during astro build

  • #6092 bf8d7366a Thanks @bholmesdev! - Ensure vite config (aliases, custom modules, etc) is respected when loading the content collection config

  • #6111 ec38a8921 Thanks @e111077! - Implement client:only functionality in Lit and add lit to the client:only warning

  • #6124 f20a85b64 Thanks @FredKSchott! - Fix outdated error message in paginate() function.

  • #6122 9f22ac3d0 Thanks @bholmesdev! - Content collections: Fix accidental "use underscore to ignore" logs for .DS_Store files and underscored directory names.

  • #6163 cee70f5c6 Thanks @Princesseuh! - Fix returning hex / base64 images from endpoints not working in dev

  • #6114 ac7fb04d6 Thanks @bluwy! - Fix sourcemap generation when scanning files

  • #6152 d1f5611fe Thanks @matthewp! - Fix MDX related head placement bugs

    This fixes a variety of head content placement bugs (such as page <link>) related to MDX, especially when used in content collections. Issues fixed:

    • Head content being placed in the body instead of the head.
    • Head content missing when rendering an MDX component from within a nested Astro component.
  • #6119 2189170be Thanks @matthewp! - Fix hoisted script propagation in content collection pages

  • #6117 32abe49bd Thanks @Princesseuh! - Fix polyfills not being available in certain cases

2.0.6

Patch Changes

2.0.5

Patch Changes

  • #6052 9793f19ec Thanks @mayank99! - Error overlay will now show the error's cause if available.

  • #6070 f91615f5c Thanks @AirBorne04! - * safe guard against TextEncode.encode(HTMLString) [errors on vercel edge]

    • safe guard against html.replace when html is undefined
  • #6064 2fb72c887 Thanks @bholmesdev! - Apply MDX components export when rendering as a content collection entry

2.0.4

Patch Changes

2.0.3

Patch Changes

2.0.2

Patch Changes

2.0.1

Patch Changes

2.0.0

Note This is a detailed changelog of all changes in Astro v2.
See our upgrade guide for an overview of steps needed to upgrade an existing project.

Major Changes

  • #5687 e2019be6f Thanks @bholmesdev! - Give remark and rehype plugins access to user frontmatter via frontmatter injection. This means data.astro.frontmatter is now the complete Markdown or MDX document's frontmatter, rather than an empty object.

    This allows plugin authors to modify existing frontmatter, or compute new properties based on other properties. For example, say you want to compute a full image URL based on an imageSrc slug in your document frontmatter:

    export function remarkInjectSocialImagePlugin() {
      return function (tree, file) {
        const { frontmatter } = file.data.astro;
        frontmatter.socialImageSrc = new URL(frontmatter.imageSrc, 'https://my-blog.com/').pathname;
      };
    }

    When using Content Collections, you can access this modified frontmatter using the remarkPluginFrontmatter property returned when rendering an entry.

    Migration instructions

    Plugin authors should now check for user frontmatter when applying defaults.

    For example, say a remark plugin wants to apply a default title if none is present. Add a conditional to check if the property is present, and update if none exists:

    export function remarkInjectTitlePlugin() {
      return function (tree, file) {
        const { frontmatter } = file.data.astro;
    +    if (!frontmatter.title) {
          frontmatter.title = 'Default title';
    +    }
      }
    }

    This differs from previous behavior, where a Markdown file's frontmatter would always override frontmatter injected via remark or reype.

  • #5891 05caf445d Thanks @bholmesdev! - Remove deprecated Markdown APIs from Astro v0.X. This includes getHeaders(), the .astro property for layouts, and the rawContent() and compiledContent() error messages for MDX.

  • #5778 49ab4f231 Thanks @bluwy! - Remove proload to load the Astro config. It will now use NodeJS and Vite to load the config only.

  • #5728 8fb28648f Thanks @natemoo-re! - The previously experimental features --experimental-error-overlay and --experimental-prerender, both added in v1.7.0, are now the default.

    You'll notice that the error overlay during astro dev has a refreshed visual design and provides more context for your errors.

    The prerender feature is now enabled by default when using output: 'server'. To prerender a particular page, add export const prerender = true to your frontmatter.

    Warning Integration authors that previously relied on the exact structure of Astro's v1.0 build output may notice some changes to our output file structure. Please test your integrations to ensure compatability. Users that have configured a custom vite.build.rollupOptions.output.chunkFileNames should ensure that their Astro project is configured as an ESM Node project. Either include "type": "module" in your root package.json file or use the .mjs extension for chunkFileNames.

  • #5782 1f92d64ea Thanks @Princesseuh! - Remove support for Node 14. Minimum supported Node version is now >=16.12.0

  • #5771 259a539d7 Thanks @matthewp! - Removes support for astroFlavoredMarkdown

    In 1.0 Astro moved the old Astro Flavored Markdown (also sometimes called Components in Markdown) to a legacy feature. This change removes the legacy.astroFlavoredMarkdown option completely.

    In 2.0 this feature will not be available in Astro at all. We recommend migration to MDX for those were still using this feature in 1.x.

  • #5941 304823811 Thanks @bholmesdev! - Content collections: Introduce a new slug frontmatter field for overriding the generated slug. This replaces the previous slug() 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 the getEntryBySlug() 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 to slug frontmatter properties in each collection entry.

    Additionally, Astro no longer allows slug as a collection schema property. This ensures Astro can manage the slug property for type generation and performance. Remove this property from your schema and any relevant slug() configuration:

    const blog = defineCollection({
      schema: z.object({
    -   slug: z.string().optional(),
      }),
    - slug({ defaultSlug, data }) {
    -   return data.slug ?? defaultSlug;
    - },
    })
  • #5753 302e0ef8f Thanks @bluwy! - Default preview host to localhost instead of 127.0.0.1. This allows the static server and integration preview servers to serve under ipv6.

  • #5716 dd56c1941 Thanks @bluwy! - Remove MDX Fragment hack. This was used by @astrojs/mdx to access the Fragment component, but isn't required anymore since @astrojs/mdx v0.12.1.

  • #5584 9963c6e4d & #5842 c4b0cb8bf Thanks @wulinsheng123 and @natemoo-re! - Breaking Change: client assets are built to an _astro directory in the build output directory. Previously these were built to various locations, including assets/, chunks/ and the root of build output.

    You can control this location with the new build configuration option named assets.

  • #5893 be901dc98 Thanks @matthewp! - Rename getEntry to getEntryBySlug

    This change moves getEntry to getEntryBySlug and accepts a slug rather than an id.

    In order to improve support in [id].astro routes, particularly in SSR where you do not know what the id of a collection is. Using getEntryBySlug instead allows you to map the [id] param in your route to the entry. You can use it like this:

    ---
    import { getEntryBySlug } from 'astro:content';
    
    const entry = await getEntryBySlug('docs', Astro.params.id);
    
    if (!entry) {
      return new Response(null, {
        status: 404,
      });
    }
    ---
    
    <!-- You have an entry! Use it! -->
  • #5685 f6cf92b48 Thanks @bluwy! - Upgrade to Vite 4. Please see its migration guide for more information.

  • #5724 16c7d0bfd Thanks @bluwy! - Remove outdated Vue info log. Remove toString support for RenderTemplateResult.

  • #5684 a9c292026 & #5769 93e633922 Thanks @bholmesdev! - Refine Markdown and MDX configuration options for ease-of-use.

    • Markdown

      • Replace the extendDefaultPlugins option with a gfm boolean and a smartypants boolean. These are enabled by default, and can be disabled to remove GitHub-Flavored Markdown and SmartyPants.

      • Ensure GitHub-Flavored Markdown and SmartyPants are applied whether or not custom remarkPlugins or rehypePlugins are configured. If you want to apply custom plugins and remove Astro's default plugins, manually set gfm: false and smartypants: false in your config.

    • Migrate extendDefaultPlugins to gfm and smartypants

      You may have disabled Astro's built-in plugins (GitHub-Flavored Markdown and Smartypants) with the extendDefaultPlugins option. This has now been split into 2 flags to disable each plugin individually:

      • markdown.gfm to disable GitHub-Flavored Markdown
      • markdown.smartypants to disable SmartyPants
      // astro.config.mjs
      import { defineConfig } from 'astro/config';
      
      export default defineConfig({
        markdown: {
      -   extendDefaultPlugins: false,
      +   smartypants: false,
      +   gfm: false,
        }
      });

      Additionally, applying remark and rehype plugins no longer disables gfm and smartypants. You will need to opt-out manually by setting gfm and smartypants to false.

    • MDX

      • Support all Markdown configuration options (except drafts) from your MDX integration config. This includes syntaxHighlighting and shikiConfig options to further customize the MDX renderer.

      • Simplify extendPlugins to an extendMarkdownConfig option. MDX options will default to their equivalent in your Markdown config. By setting extendMarkdownConfig to false, you can "eject" to set your own syntax highlighting, plugins, and more.

    • Migrate MDX's extendPlugins to extendMarkdownConfig

      You may have used the extendPlugins option to manage plugin defaults in MDX. This has been replaced by 3 flags:

      • extendMarkdownConfig (true by default) to toggle Markdown config inheritance. This replaces the extendPlugins: 'markdown' option.
      • gfm (true by default) and smartypants (true by default) to toggle GitHub-Flavored Markdown and SmartyPants in MDX. This replaces the extendPlugins: 'defaults' option.
  • #5717 a3a7fc929 Thanks @bluwy! - Remove style.postcss Astro config. Refactor tailwind integration to configure through vite instead. Also disables autoprefixer in dev.

  • #5825 52209ca2a Thanks @bholmesdev! - Baseline the experimental contentCollections flag. You're free to remove this from your astro config!

    import { defineConfig } from 'astro/config';
    
    export default defineConfig({
    - experimental: { contentCollections: true }
    })
    
  • #5707 5eba34fcc Thanks @bluwy! - Remove deprecated Astro global APIs, including Astro.resolve, Astro.fetchContent, and Astro.canonicalURL.

    • Astro.resolve

      You can resolve asset paths using import instead. For example:

      ---
      import 'style.css';
      import imageUrl from './image.png';
      ---
      
      <img src={imageUrl} />

      See the v0.25 migration guide for more information.

    • Astro.fetchContent

      Use Astro.glob instead to fetch markdown files, or migrate to the Content Collections feature.

      let allPosts = await Astro.glob('./posts/*.md');
    • Astro.canonicalURL

      Use Astro.url instead to construct the canonical URL.

      const canonicalURL = new URL(Astro.url.pathname, Astro.site);
  • #5608 899214298 Thanks @konojunya! - A trailing slash will not be automatically appended to import.meta.env.SITE. Instead, it will be the value of the site config as is. This may affect usages of ${import.meta.env.SITE}image.png, which will need to be updated accordingly.

  • #5707 5eba34fcc Thanks @bluwy! - Remove buildConfig option parameter from integration astro:build:start hook in favour of the build.config option in the astro:config:setup hook.

    export default function myIntegration() {
      return {
        name: 'my-integration',
        hooks: {
          'astro:config:setup': ({ updateConfig }) => {
            updateConfig({
              build: {
                client: '...',
                server: '...',
                serverEntry: '...',
              },
            });
          },
        },
      };
    }
  • #5862 1ca81c16b Thanks @bluwy! - Remove unused exports

Minor Changes

  • #5901 a342a486c Thanks @bluwy! - The fallback Svelte preprocessor will only be applied if a custom preprocess option is not passed to the svelte() integration option, or in the svelte.config.js file.

    To support IDE autocompletion, or if you're migrating from @astrojs/svelte v1, you can create a svelte.config.js file with:

    import { vitePreprocess } from '@astrojs/svelte';
    
    export default {
      preprocess: vitePreprocess(),
    };

    This file will also be generated by astro add svelte by default.

  • #5786 c2180746b Thanks @bholmesdev! - Move generated content collection types to a .astro directory. This replaces the previously generated src/content/types.generated.d.ts file.

    If you're using Git for version control, we recommend ignoring this generated directory by adding .astro to your .gitignore.

    Astro will also generate the TypeScript reference path to include .astro types in your project. This will update your project's src/env.d.ts file, or write one if none exists.

  • #5826 840412128 Thanks @bholmesdev! - Allow Zod objects, unions, discriminated unions, intersections, and transform results as content collection schemas.

    Migration

    Astro requires a z.object(...) wrapper on all content collection schemas. Update your content collections config like so:

    // src/content/config.ts
    import { z, defineCollection } from 'astro:content';
    
    const blog = defineCollection({
    - schema: {
    + schema: z.object({
      ...
    })
  • #5823 1f49cddf9 Thanks @delucis! - Generate content types when running astro check

  • #5832 2303f9514 Thanks @HiDeoo! - Add support for serving well-known URIs with the @astrojs/node SSR adapter

Patch Changes

2.0.0-beta.4

See changes in 2.0.0-beta.4

Major Changes

  • #5941 304823811 Thanks @bholmesdev! - Content collections: Introduce a new slug frontmatter field for overriding the generated slug. This replaces the previous slug() 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 the getEntryBySlug() 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 to slug frontmatter properties in each collection entry.

    Additionally, Astro no longer allows slug as a collection schema property. This ensures Astro can manage the slug property for type generation and performance. Remove this property from your schema and any relevant slug() configuration:

    const blog = defineCollection({
      schema: z.object({
    -   slug: z.string().optional(),
      }),
    - slug({ defaultSlug, data }) {
    -   return data.slug ?? defaultSlug;
    - },
    })

Patch Changes

2.0.0-beta.3

See changes in 2.0.0-beta.3

Major Changes

  • #5891 05caf445d Thanks @bholmesdev! - Remove deprecated Markdown APIs from Astro v0.X. This includes getHeaders(), the .astro property for layouts, and the rawContent() and compiledContent() error messages for MDX.

  • #5893 be901dc98 Thanks @matthewp! - Move getEntry to getEntryBySlug

    This change moves getEntry to getEntryBySlug and accepts a slug rather than an id.

    In order to improve support in [id].astro routes, particularly in SSR where you do not know what the id of a collection is. Using getEntryBySlug instead allows you to map the [id] param in your route to the entry. You can use it like this:

    ---
    import { getEntryBySlug } from 'astro:content';
    
    const entry = await getEntryBySlug('docs', Astro.params.id);
    
    if (!entry) {
      return new Response(null, {
        status: 404,
      });
    }
    ---
    
    <!-- You have an entry! Use it! -->
  • #5608 899214298 Thanks @konojunya! - A trailing slash will not be automatically appended to import.meta.env.SITE. Instead, it will be the value of the site config as is. This may affect usages of ${import.meta.env.SITE}image.png, which will need to be updated accordingly.

  • #5862 1ca81c16b Thanks @bluwy! - Remove unused exports

Minor Changes

  • #5901 a342a486c Thanks @bluwy! - The fallback Svelte preprocessor will only be applied if a custom preprocess option is not passed to the svelte() integration option, or in the svelte.config.js file.

    To support IDE autocompletion, or if you're migrating from @astrojs/svelte v1, you can create a svelte.config.js file with:

    import { vitePreprocess } from '@astrojs/svelte';
    
    export default {
      preprocess: vitePreprocess(),
    };

    This file will also be generated by astro add svelte by default.

Patch Changes

2.0.0-beta.2

See changes in 2.0.0-beta.2

Major Changes

  • #5782 1f92d64ea Thanks @Princesseuh! - Remove support for Node 14. Minimum supported Node version is now >=16.12.0

  • #5753 302e0ef8f Thanks @bluwy! - Default preview host to localhost instead of 127.0.0.1. This allows the static server and integration preview servers to serve under ipv6.

  • #5842 c4b0cb8bf Thanks @natemoo-re! - Breaking Change: client assets are built to an _astro directory in the build output directory. Previously these were built to various locations, including assets/, chunks/ and the root of build output.

    You can control this location with the new build configuration option named assets.

  • #5825 52209ca2a Thanks @bholmesdev! - Baseline the experimental contentCollections flag. You're free to remove this from your astro config!

    import { defineConfig } from 'astro/config';
    
    export default defineConfig({
    - experimental: { contentCollections: true }
    })

Minor Changes

  • #5786 c2180746b Thanks @bholmesdev! - Move generated content collection types to a .astro directory. This replaces the previously generated src/content/types.generated.d.ts file.

    If you're using Git for version control, we recommend ignoring this generated directory by adding .astro to your .gitignore.

    Astro will also generate the TypeScript reference path to include .astro types in your project. This will update your project's src/env.d.ts file, or write one if none exists.

  • #5826 840412128 Thanks @bholmesdev! - Allow Zod objects, unions, discriminated unions, intersections, and transform results as content collection schemas.

    Migration

    Astro requires a z.object(...) wrapper on all content collection schemas. Update your content collections config like so:

    // src/content/config.ts
    import { z, defineCollection } from 'astro:content';
    
    const blog = defineCollection({
    - schema: {
    + schema: z.object({
      ...
    })
  • #5823 1f49cddf9 Thanks @delucis! - Generate content types when running astro check

  • #5832 2303f9514 Thanks @HiDeoo! - Add support for serving well-known URIs with the @astrojs/node SSR adapter

Patch Changes

2.0.0-beta.1

See changes in 2.0.0-beta.1

Major Changes

  • #5778 49ab4f231 Thanks @bluwy! - Remove proload to load the Astro config. It will now use NodeJS and Vite to load the config only.

  • #5771 259a539d7 Thanks @matthewp! - Removes support for astroFlavoredMarkdown

    In 1.0 Astro moved the old Astro Flavored Markdown (also sometimes called Components in Markdown) to a legacy feature. This change removes the legacy.astroFlavoredMarkdown option completely.

    In 2.0 this feature will not be available in Astro at all. We recommend migration to MDX for those were still using this feature in 1.x.

  • #5717 a3a7fc929 Thanks @bluwy! - Remove style.postcss Astro config. Refactor tailwind integration to configure through vite instead. Also disables autoprefixer in dev.

Minor Changes

  • #5769 93e633922 Thanks @bholmesdev! - Introduce a smartypants flag to opt-out of Astro's default SmartyPants plugin.

    {
      markdown: {
        smartypants: false,
      }
    }

    Migration

    You may have disabled Astro's built-in plugins (GitHub-Flavored Markdown and Smartypants) with the extendDefaultPlugins option. This has now been split into 2 flags to disable each plugin individually:

    • markdown.gfm to disable GitHub-Flavored Markdown
    • markdown.smartypants to disable SmartyPants
    // astro.config.mjs
    import { defineConfig } from 'astro/config';
    
    export default defineConfig({
      markdown: {
    -   extendDefaultPlugins: false,
    +   smartypants: false,
    +   gfm: false,
      }
    });

Patch Changes

2.0.0-beta.0

See changes in 2.0.0-beta.0

Major Changes

  • #5687 e2019be6f Thanks @bholmesdev! - Give remark and rehype plugins access to user frontmatter via frontmatter injection. This means data.astro.frontmatter is now the complete Markdown or MDX document's frontmatter, rather than an empty object.

    This allows plugin authors to modify existing frontmatter, or compute new properties based on other properties. For example, say you want to compute a full image URL based on an imageSrc slug in your document frontmatter:

    export function remarkInjectSocialImagePlugin() {
      return function (tree, file) {
        const { frontmatter } = file.data.astro;
        frontmatter.socialImageSrc = new URL(frontmatter.imageSrc, 'https://my-blog.com/').pathname;
      };
    }

    Content Collections - new remarkPluginFrontmatter property

    We have changed inject frontmatter to modify frontmatter in our docs to improve discoverability. This is based on support forum feedback, where "injection" is rarely the term used.

    To reflect this, the injectedFrontmatter property has been renamed to remarkPluginFrontmatter. This should clarify this plugin is still separate from the data export Content Collections expose today.

    Migration instructions

    Plugin authors should now check for user frontmatter when applying defaults.

    For example, say a remark plugin wants to apply a default title if none is present. Add a conditional to check if the property is present, and update if none exists:

    export function remarkInjectTitlePlugin() {
      return function (tree, file) {
        const { frontmatter } = file.data.astro;
    +    if (!frontmatter.title) {
          frontmatter.title = 'Default title';
    +    }
      }
    }

    This differs from previous behavior, where a Markdown file's frontmatter would always override frontmatter injected via remark or reype.

  • #5728 8fb28648f Thanks @natemoo-re! - The previously experimental features --experimental-error-overlay and --experimental-prerender, both added in v1.7.0, are now the default.

    You'll notice that the error overlay during astro dev has a refreshed visual design and provides more context for your errors.

    The prerender feature is now enabled by default when using output: 'server'. To prerender a particular page, add export const prerender = true to your frontmatter.

    Warning Integration authors that previously relied on the exact structure of Astro's v1.0 build output may notice some changes to our output file structure. Please test your integrations to ensure compatability. Users that have configured a custom vite.build.rollupOptions.output.chunkFileNames should ensure that their Astro project is configured as an ESM Node project. Either include "type": "module" in your root package.json file or use the .mjs extension for chunkFileNames.

  • #5716 dd56c1941 Thanks @bluwy! - Remove MDX Fragment hack. This was used by @astrojs/mdx to access the Fragment component, but isn't require anymore since @astrojs/mdx v0.12.1.

  • #5685 f6cf92b48 Thanks @bluwy! - Upgrade to Vite 4. Please see its migration guide for more information.

  • #5724 16c7d0bfd Thanks @bluwy! - Remove outdated Vue info log. Remove toString support for RenderTemplateResult.

  • #5684 a9c292026 Thanks @bholmesdev! - Refine Markdown and MDX configuration options for ease-of-use.

    Markdown

    • Remove remark-smartypants from Astro's default Markdown plugins.
    • Replace the extendDefaultPlugins option with a simplified gfm boolean. This is enabled by default, and can be disabled to remove GitHub-Flavored Markdown.
    • Ensure GitHub-Flavored Markdown is applied whether or not custom remarkPlugins or rehypePlugins are configured. If you want to apply custom plugins and remove GFM, manually set gfm: false in your config.

    MDX

    • Support all Markdown configuration options (except drafts) from your MDX integration config. This includes syntaxHighlighting and shikiConfig options to further customize the MDX renderer.
    • Simplify extendDefaults to an extendMarkdownConfig option. MDX options will default to their equivalent in your Markdown config. By setting extendMarkdownConfig to false, you can "eject" to set your own syntax highlighting, plugins, and more.

    Migration

    To preserve your existing Markdown and MDX setup, you may need some configuration changes:

    Smartypants manual installation

    Smartypants has been removed from Astro's default setup. If you rely on this plugin, install remark-smartypants and apply to your astro.config.*:

    // astro.config.mjs
    import { defineConfig } from 'astro/config';
    + import smartypants from 'remark-smartypants';
    
    export default defineConfig({
      markdown: {
    +   remarkPlugins: [smartypants],
      }
    });
    Migrate extendDefaultPlugins to gfm

    You may have disabled Astro's built-in plugins (GitHub-Flavored Markdown and Smartypants) with the extendDefaultPlugins option. Since Smartypants has been removed, this has been renamed to gfm.

    // astro.config.mjs
    import { defineConfig } from 'astro/config';
    
    export default defineConfig({
      markdown: {
    -   extendDefaultPlugins: false,
    +   gfm: false,
      }
    });

    Additionally, applying remark and rehype plugins no longer disables gfm. You will need to opt-out manually by setting gfm to false.

    Migrate MDX's extendPlugins to extendMarkdownConfig

    You may have used the extendPlugins option to manage plugin defaults in MDX. This has been replaced by 2 flags:

    • extendMarkdownConfig (true by default) to toggle Markdown config inheritance. This replaces the extendPlugins: 'markdown' option.
    • gfm (true by default) to toggle GitHub-Flavored Markdown in MDX. This replaces the extendPlugins: 'defaults' option.
  • #5707 5eba34fcc Thanks @bluwy! - Remove deprecated Astro global APIs, including Astro.resolve, Astro.fetchContent, and Astro.canonicalURL.

    Astro.resolve

    You can resolve asset paths using import instead. For example:

    ---
    import 'style.css';
    import imageUrl from './image.png';
    ---
    
    <img src={imageUrl} />

    See the v0.25 migration guide for more information.

    Astro.fetchContent

    Use Astro.glob instead to fetch markdown files, or migrate to the Content Collections feature.

    let allPosts = await Astro.glob('./posts/*.md');

    Astro.canonicalURL

    Use Astro.url instead to construct the canonical URL.

    const canonicalURL = new URL(Astro.url.pathname, Astro.site);
  • #5707 5eba34fcc Thanks @bluwy! - Remove buildConfig option parameter from integration astro:build:start hook in favour of the build.config option in the astro:config:setup hook.

    export default function myIntegration() {
      return {
        name: 'my-integration',
        hooks: {
          'astro:config:setup': ({ updateConfig }) => {
            updateConfig({
              build: {
                client: '...',
                server: '...',
                serverEntry: '...',
              },
            });
          },
        },
      };
    }

Patch Changes

1.9.2

Patch Changes

1.9.1

Patch Changes

  • adad7e966 Thanks @matthewp! - Fix for hoisted scripts in project with spaces in the file path

1.9.0

Minor Changes

  • #5666 bf210f784 Thanks @bholmesdev! - Correctly handle spaces and capitalization in src/content/ file names. This introduces github-slugger for slug generation to ensure slugs are usable by getStaticPaths. Changes:
    • Resolve spaces and capitalization: collection/Entry With Spaces.md becomes collection/entry-with-spaces.
    • Truncate /index paths to base URL: collection/index.md becomes collection

Patch Changes

1.8.0

Minor Changes

Patch Changes

1.7.2

Patch Changes

1.7.1

Patch Changes

  • #5617 33dcaa05b Thanks @bholmesdev! - Fix error message when using Content Collections and an out-of-date @astrojs/mdx integration

1.7.0

Minor Changes

  • #5297 d2960984c Thanks @natemoo-re! - Introduces the experimental Prerender API.

    Note This API is not yet stable and is subject to possible breaking changes!

    • Deploy an Astro server without sacrificing the speed or cacheability of static HTML.
    • The Prerender API allows you to statically prerender specific pages/ at build time.

    Usage

    • First, run astro build --experimental-prerender or enable experimental: { prerender: true } in your astro.config.mjs file.
    • Then, include export const prerender = true in any file in the pages/ directory that you wish to prerender.
  • #5495 31ec84797 Thanks @Princesseuh! - Add a new error overlay designed by @doodlemarks! This new overlay should be much more informative, clearer, astro-y, and prettier than the previous one.

  • #5291 5ec0f6ed5 Thanks @bholmesdev! - Introduce Content Collections experimental API

    • Organize your Markdown and MDX content into easy-to-manage collections.
    • Add type safety to your frontmatter with schemas.
    • Generate landing pages, static routes, and SSR endpoints from your content using the collection query APIs.
  • #5564 dced4a8a2 Thanks @riywo! - Add server.headers option

  • #5341 6b156dd3b Thanks @alexpdraper! - Allow setting domain when deleting cookies

Patch Changes

1.6.15

Patch Changes

1.6.14

Patch Changes

1.6.13

Patch Changes

1.6.12

Patch Changes

1.6.11

Patch Changes

1.6.10

Patch Changes

1.6.9

Patch Changes

1.6.8

Patch Changes

1.6.7

Patch Changes

1.6.6

Patch Changes

1.6.5

Patch Changes

1.6.4

Patch Changes

  • #5290 b2b291d29 Thanks @matthewp! - Handle base configuration in adapters

    This allows adapters to correctly handle base configuration. Internally Astro now matches routes when the URL includes the base.

    Adapters now also have access to the removeBase method which will remove the base from a pathname. This is useful to look up files for static assets.

  • #5292 97e2b6ad7 Thanks @MontelAle! - Changes slow astro cli imports to dynamic

  • #5293 4af4d8fa0 Thanks @matthewp! - Prevent overcaching .astro HMR changes

  • #5314 f6add3924 Thanks @matthewp! - Fixes regression with config file restarts

  • #5298 247eb7411 Thanks @wulinsheng123! - have not founded style when srcDir was root

1.6.3

Patch Changes

  • #5273 c7b9b14a1 Thanks @matthewp! - Surface astro.config errors to the user

  • #5264 0d27c4a2b Thanks @VladCuciureanu! - Fixed memleak caused by project dir names containing '.md' or '.mdx'

  • #5258 74759cf78 Thanks @bluwy! - Allow 200 response for endpoints in build

  • #5284 126cd8e83 Thanks @herteleo! - Include missing class:list within HTMLAttributes type

  • #5236 1cc067052 Thanks @bluwy! - Refactor CSS preprocessing handling

  • #5198 c77a6cbe3 Thanks @matthewp! - HMR - Improved error recovery

    This improves error recovery for HMR. Now when the dev server finds itself in an error state (because a route contained an error), it will recover from that state and refresh the page when the user has corrected the mistake.

1.6.2

Patch Changes

1.6.1

Patch Changes

1.6.0

Minor Changes

  • #5147 0bf0758fb Thanks @natemoo-re! - Add astro/types entrypoint. These utilities can be used for common prop type patterns.

    HTMLAttributes

    If you would like to extend valid HTML attributes for a given HTML element, you may use the provided HTMLAttributes type—it accepts an element name and returns the valid HTML attributes for that element name.

    import { HTMLAttributes } from 'astro/types';
    interface Props extends HTMLAttributes<'a'> {
      myProp?: string;
    }
  • #5164 4a8a346ca Thanks @MoustaphaDev! - Add support for markdown files with the following extensions:

    • .markdown
    • .mdown
    • .mkdn
    • .mkd
    • .mdwn
  • #4917 ddf2f8390 Thanks @natemoo-re! - Add support for --base CLI argument, which will override the base set in your astro.config.mjs file.

    astro --site https://astro.build --base /docs
    

Patch Changes

1.5.3

Patch Changes

  • #5133 1c477dd8d Thanks @bluwy! - Fix .css?raw usage

  • #5133 1c477dd8d Thanks @bluwy! - Update @astrojs/compiler and use the new resolvePath option. This allows removing much of the runtime code, which should improve rendering performance for Astro and MDX pages.

  • #5192 8728ee0b9 Thanks @tony-sull! - astro add no longer automatically installs optional peer dependencies

1.5.2

Patch Changes

1.5.1

Patch Changes

1.5.0

Minor Changes

  • #5056 e55af8a23 Thanks @matthewp! - # Adapter support for astro preview

    Adapters are now about to support the astro preview command via a new integration option. The Node.js adapter @astrojs/node is the first of the built-in adapters to gain support for this. What this means is that if you are using @astrojs/node you can new preview your SSR app by running:

    npm run preview

    Adapter API

    We will be updating the other first party Astro adapters to support preview over time. Adapters can opt-in to this feature by providing the previewEntrypoint via the setAdapter function in astro:config:done hook. The Node.js adapter's code looks like this:

    export default function() {
      return {
    		name: '@astrojs/node',
    		hooks: {
    			'astro:config:done': ({ setAdapter, config }) => {
            setAdapter({
              name: '@astrojs/node',
              serverEntrypoint: '@astrojs/node/server.js',
    +          previewEntrypoint: '@astrojs/node/preview.js',
              exports: ['handler'],
            });
    
            // more here
          }
        }
      };
    }

    The previewEntrypoint is a module in the adapter's package that is a Node.js script. This script is run when astro preview is run and is charged with starting up the built server. See the Node.js implementation in @astrojs/node to see how that is implemented.

  • #4986 ebd364e39 Thanks @bluwy! - ## New properties for API routes

    In API routes, you can now get the site, generator, url, clientAddress, props, and redirect fields on the APIContext, which is the first parameter passed to an API route. This was done to make the APIContext more closely align with the Astro global in .astro pages.

    For example, here's how you might use the clientAddress, which is the user's IP address, to selectively allow users.

    export function post({ clientAddress, request, redirect }) {
      if (!allowList.has(clientAddress)) {
        return redirect('/not-allowed');
      }
    }

    Check out the docs for more information on the newly available fields: https://docs.astro.build/en/core-concepts/endpoints/#server-endpoints-api-routes

  • #4959 0ea6187f9 Thanks @Princesseuh! - Added support for updating TypeScript settings automatically when using astro add

    The astro add command will now automatically update your tsconfig.json with the proper TypeScript settings needed for the chosen frameworks.

    For instance, typing astro add solid will update your tsconfig.json with the following settings, per Solid's TypeScript guide:

    {
      "compilerOptions": {
        "jsx": "preserve",
        "jsxImportSource": "solid-js"
      }
    }
  • #4947 a5e3ecc80 Thanks @JuanM04! - - Added isRestart and addWatchFile to integration step isRestart.

    • Restart dev server automatically when tsconfig changes.
  • #4986 ebd364e39 Thanks @bluwy! - ## Support passing a custom status code for Astro.redirect

    New in this minor is the ability to pass a status code to Astro.redirect. By default it uses 302 but now you can pass another code as the second argument:

    ---
    // This page was moved
    return Astro.redirect('/posts/new-post-name', 301);
    ---
  • #5056 e55af8a23 Thanks @matthewp! - # New build configuration

    The ability to customize SSR build configuration more granularly is now available in Astro. You can now customize the output folder for server (the server code for SSR), client (your client-side JavaScript and assets), and serverEntry (the name of the entrypoint server module). Here are the defaults:

    import { defineConfig } from 'astro/config';
    
    export default defineConfig({
      output: 'server',
      build: {
        server: './dist/server/',
        client: './dist/client/',
        serverEntry: 'entry.mjs',
      },
    });

    These new configuration options are only supported in SSR mode and are ignored when building to SSG (a static site).

    Integration hook change

    The integration hook astro:build:start includes a param buildConfig which includes all of these same options. You can continue to use this param in Astro 1.x, but it is deprecated in favor of the new build.config options. All of the built-in adapters have been updated to the new format. If you have an integration that depends on this param we suggest upgrading to do this instead:

    export default function myIntegration() {
      return {
        name: 'my-integration',
        hooks: {
          'astro:config:setup': ({ updateConfig }) => {
            updateConfig({
              build: {
                server: '...',
              },
            });
          },
        },
      };
    }

Patch Changes

  • #5057 baf88ee9e Thanks @bluwy! - Skip JSX tagging for export statements with source

  • #5044 44ea0c6d9 Thanks @JuanM04! - Upgrade Astro compiler to 0.27.1

  • #5059 f7fcdfe62 Thanks @bluwy! - Support strict dependency install for libraries with JSX

  • #5047 1e2799243 Thanks @matthewp! - Update Astro.cookies.set types to allow booleans and numbers

    Note that booleans and numbers were already allowed, they just were not allowed by the type definitions.

1.4.7

Patch Changes

  • #5035 d7bfb144b Thanks @AirBorne04! - preventing multiple doctype injection into html documents

  • #5015 b1964e9e1 Thanks @matthewp! - Shared state in Preact components with signals

    This makes it possible to share client state between Preact islands via signals.

    For example, you can create a signals in an Astro component and then pass it to multiple islands:

    ---
    // Component Imports
    import Counter from '../components/Counter';
    import { signal } from '@preact/signals';
    const count = signal(0);
    ---
    
    <Count count={count} />
    <Count count={count} />
  • #5036 38fdb4ca6 Thanks @matthewp! - New algorithm for shorter CSS bundle names

1.4.6

Patch Changes

1.4.5

Patch Changes

1.4.4

Patch Changes

  • #4967 e6a881081 Thanks @matthewp! - Final perf fix from 1.3.0 regression

    A regression in rendering perf happened in 1.3.0. This is the final fix for the underlying issue.

1.4.3

Patch Changes

1.4.2

Patch Changes

1.4.1

Patch Changes

1.4.0

Minor Changes

  • #4907 01c1aaa00 Thanks @matthewp! - Order Astro styles last, to override imported styles

    This fixes CSS ordering so that imported styles are placed higher than page/component level styles. This means that if you do:

    ---
    import '../styles/global.css';
    ---
    
    <style>
      body {
        background: limegreen;
      }
    </style>

    The <style> defined in this component will be placed below the imported CSS. When compiled for production this will result in something like this:

    /* /src/styles/global.css */
    body {
      background: blue;
    }
    
    /* /src/pages/index.astro */
    body:where(.astro-12345) {
      background: limegreen;
    }

    Given Astro's 0-specificity hashing, this change effectively makes it so that Astro styles "win" when they have the same specificity as global styles.

  • #4876 d3091f89e Thanks @matthewp! - Adds the Astro.cookies API

    Astro.cookies is a new API for manipulating cookies in Astro components and API routes.

    In Astro components, the new Astro.cookies object is a map-like object that allows you to get, set, delete, and check for a cookie's existence (has):

    ---
    type Prefs = {
      darkMode: boolean;
    };
    
    Astro.cookies.set<Prefs>(
      'prefs',
      { darkMode: true },
      {
        expires: '1 month',
      }
    );
    
    const prefs = Astro.cookies.get<Prefs>('prefs').json();
    ---
    
    <body data-theme={prefs.darkMode ? 'dark' : 'light'}></body>

    Once you've set a cookie with Astro.cookies it will automatically be included in the outgoing response.

    This API is also available with the same functionality in API routes:

    export function post({ cookies }) {
      cookies.set('loggedIn', false);
    
      return new Response(null, {
        status: 302,
        headers: {
          Location: '/login',
        },
      });
    }

    See the RFC to learn more.

Patch Changes

1.3.1

Patch Changes

1.3.0

Minor Changes

  • #4775 b0cc93996 Thanks @tony-sull! - Adds a new "astro:build:generated" hook that runs after SSG builds finish but before build artifacts are cleaned up. This is a very specific use case, "astro:build:done" is probably what you're looking for.

  • #4669 a961aa3c2 Thanks @aggre! - astro-island now correctly passes Uint8Array/Uint16Array/Uint32Array

  • #4832 73f215df7 Thanks @matthewp! - Allows Responses to be passed to set:html

    This expands the abilities of set:html to ultimate service this use-case:

    <div set:html={fetch('/legacy-post.html')} />

    This means you can take a legacy app that has been statically generated to HTML and directly consume that HTML within your templates. As is always the case with set:html, this should only be used on trusted content.

    To make this possible, you can also pass several other types into set:html now:

    • Response objects, since that is what fetch() returns:
      <div
        set:html={new Response('<span>Hello world</span>', {
          headers: { 'content-type': 'text/html' },
        })}
      />
    • ReadableStreams:
      <div
        set:html={new ReadableStream({
          start(controller) {
            controller.enqueue(`<span>read me</span>`);
            controller.close();
          },
        })}
      />
    • AsyncIterables:
      <div
        set:html={(async function* () {
          for await (const num of [1, 2, 3, 4, 5]) {
            yield `<li>${num}</li>`;
          }
        })()}
      />
    • Iterables (non-async):
      <div
        set:html={(function* () {
          for (const num of [1, 2, 3, 4, 5]) {
            yield `<li>${num}</li>`;
          }
        })()}
      />

Patch Changes

1.2.8

Patch Changes

1.2.7

Patch Changes

1.2.6

Patch Changes

1.2.5

Patch Changes

1.2.4

Patch Changes

1.2.3

Patch Changes

1.2.2

Patch Changes

1.2.1

Patch Changes

1.2.0

Minor Changes

  • #4682 d1e695914 Thanks @bholmesdev! - astro add - move configuration updates to final step

  • #4549 255636cc7 Thanks @altano! - Allow specifying custom encoding when using a non-html route. Only option before was 'utf-8' and now that is just the default.

  • #4578 c706d845e Thanks @bholmesdev! - Restart dev server when config file is added, updated, or removed

Patch Changes

1.1.8

Patch Changes

1.1.7

Patch Changes

1.1.6

Patch Changes

1.1.5

Patch Changes

1.1.4

Patch Changes

1.1.3

Patch Changes

  • #4574 b92c24f40 Thanks @delucis! - Update astro add to list official integrations & adapters with same organisation we use in docs

1.1.2

Patch Changes

1.1.1

Patch Changes

1.1.0

Minor Changes

  • #4423 d4cd7a59f Thanks @bholmesdev! - Update Markdown type signature to match new markdown plugin,and update top-level layout props for better alignment

Patch Changes

  • #4497 78e06c8ec Thanks @bholmesdev! - Production build logging - Only log [code].html instead of [code]/index.html for 404 and 500 routes

  • Updated dependencies [ac0321824, 839097c84]:

    • @astrojs/markdown-remark@1.1.0

1.1.0-next.0

Minor Changes

  • #4423 d4cd7a59f Thanks @bholmesdev! - Update Markdown type signature to match new markdown plugin,and update top-level layout props for better alignment

Patch Changes

1.0.9

Patch Changes

1.0.8

Patch Changes

  • #4385 8164fa6f1 Thanks @krolebord! - Fix warning when using hooks inside the react components not exported as a function declaration
  • #4446 27ac6a03a Thanks @matthewp! - Deterministic CSS ordering

    This makes our CSS link order deterministic. It uses CSS depth; that is how deeply a module import the CSS comes from, in order to determine which CSS is page-level vs. component-level CSS.

    This is intended to match dev ordering where, because we do not bundle, the page-level CSS always comes after component-level.

1.0.7

Patch Changes

1.0.6

Patch Changes

1.0.5

Patch Changes

  • #4302 1d3a0a16f Thanks @FredKSchott! - Revert "Ensure hydration scripts inside of slots render ASAP (#4288)" to fix Svelte integration bug

1.0.4

Patch Changes

  • #4268 f7afdb889 Thanks @bholmesdev! - Align MD with MDX on layout props and "glob" import results:
    • Add Content to MDX
    • Add file and url to MDX frontmatter (layout import only)
    • Update glob types to reflect differences (lack of rawContent and compiledContent)

1.0.3

Patch Changes

1.0.2

Patch Changes

1.0.1

Patch Changes

1.0.0

Astro v1.0 is out! Read the official announcement post.

Note If you need help migrating an existing Astro project to the new Astro v1.0, check out our updated Migration Guide and full documentation website.

0.X

For older changelog entries -- including all v0.X, v1.0 Beta, and v1.0 Release Candidate versions -- check out the v0.X changelog.