astro 2.5.0
Minor Changes
-
#7071
e186ecc5eThanks @johannesspohr! - Render sibling components in parallel -
#6850
c6d7ebefdThanks @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
719002ca5Thanks @MoustaphaDev! - Enable experimental support for hybrid SSR with pre-rendering enabled by defaultastro.config.mjs
import { defineConfig } from 'astro/config'; export defaultdefineConfig({ output: 'hybrid', experimental: { hybridOutput: true, }, })Then add
export const prerender = falseto 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
73ec6f6c1Thanks @bluwy! - Integrations can add newclient:directives through theastro:config:setuphook'saddClientDirective()API. To enable this API, the user needs to setexperimental.customClientDirectivestotruein 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 typeClientDirective: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
763ff2d1eThanks @wulinsheng123! - Adds an opt-in way to minify the HTML output.Using the
compressHTMLoption Astro will remove whitespace from Astro components. This only applies to components written in.astroformat 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
c1669c001Thanks @Princesseuh! - AddedPolymorphictype helper toastro/typesto 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
3d525efc9Thanks @matthewp! - Prevent removal of nested slots within islandsThis 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
-
#7102
4516d7b22Thanks @Princesseuh! - Fix image services not being usable on Edge runtimes -
#7044
914c439bcThanks @Steffan153! - Escape closing script tag withdefine:vars -
#6851
e9fc2c221Thanks @timozander! - Added warning message when using unsupported file extensions in pages/ -
#7106
075eee08fThanks @ematipico! - Fix middleware for API endpoints that useResponse, and log a warning for endpoints that don't useResponse. -
#7110
fc52681baThanks @delucis! - Fix formatting in theNoMatchingRenderererror message. -
#7095
fb84622afThanks @bholmesdev! - Generate headingids and populate theheadingsproperty for all Markdoc files -
#7011
cada10a46Thanks @TheOtterlord! - Throw an error when unknown experimental keys are present -
#7091
cd410c5ebThanks @MoustaphaDev! - Fix double prepended forward slash in SSR -
#7108
410428672Thanks @Princesseuh! - Fix imports using ?raw and ?url not working whenexperimental.assetsis enabled -
Updated dependencies [
826e02890]:- @astrojs/markdown-remark@2.2.1