惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

H
Help Net Security
C
Cybersecurity and Infrastructure Security Agency CISA
S
Secure Thoughts
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Hacker News: Ask HN
Hacker News: Ask HN
Attack and Defense Labs
Attack and Defense Labs
N
News and Events Feed by Topic
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
A
Arctic Wolf
www.infosecurity-magazine.com
www.infosecurity-magazine.com
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
The GitHub Blog
The GitHub Blog
W
WeLiveSecurity
Simon Willison's Weblog
Simon Willison's Weblog
WordPress大学
WordPress大学
Y
Y Combinator Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Forbes - Security
Forbes - Security
NISL@THU
NISL@THU
博客园 - 聂微东
G
Google Developers Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Schneier on Security
Schneier on Security
V
Vulnerabilities – Threatpost
V
V2EX
I
Intezer
S
Schneier on Security
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
雷峰网
雷峰网
L
LangChain Blog
小众软件
小众软件
Hugging Face - Blog
Hugging Face - Blog
T
The Blog of Author Tim Ferriss
L
LINUX DO - 热门话题
P
Proofpoint News Feed
Microsoft Security Blog
Microsoft Security Blog
Project Zero
Project Zero
V
Visual Studio Blog
Engineering at Meta
Engineering at Meta
爱范儿
爱范儿
H
Hacker News: Front Page
B
Blog
T
Threatpost
Spread Privacy
Spread Privacy
H
Heimdal Security Blog
F
Fortinet All Blogs
TaoSecurity Blog
TaoSecurity Blog
T
Threat Research - Cisco Blogs
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
The Cloudflare Blog

The Astro Blog

Astro 6.4 Astro 6.3 Starlight 0.39 Astro 6.2 What's new in Astro - April 2026 What's new in Astro - March 2026 Astro 6.1 CloudCannon Joins Astro as an Official CMS Partner Astro 6.0 What's new in Astro - February 2026 What's new in Astro - January 2026 Astro 5.17 Supporting the future of Astro The Astro Technology Company joins Cloudflare Astro 6 Beta What's new in Astro - December 2025 What's new in Astro - November 2025 Astro 5.16 Stainless Sponsors Astro, Launches Astro-Powered Docs Platform What's new in Astro - October 2025 Astro 5.15 Spirit of Astro: meet the winning designs What's new in Astro - September 2025 Astro 5.14 Cloudflare Donates $150,000 to Support Astro's Open Source Mission Webflow Donates $150,000 to Support Astro's Open Source Mission Mux: Our Official Video Partner Unleashing creativity: How CodeTV built a video streaming platform with Astro and Mux | Astro What's new in Astro - August 2025 Astro 5.13 What's new in Astro - July 2025 Astro 5.12 Starlight 0.35 Astro 5.11 What's new in Astro - June 2025 Live Content Collections: A Deep Dive Introducing… Astro Mart Astro Solstice Festival Astro 5.10 Astro 5.9 What's new in Astro - May 2025 Astro 5.8 What's new in Astro - April 2025 2025 Technical Steering Committee Starlight April Update Astro 5.7 Astro Agency Partner Program Astro 5.6 What's new in Astro - March 2025 Astro 5.5 What's new in Astro - February 2025 Astro 5.4 Starlight 0.32 Astro 5.3 What's new in Astro - January 2025 Astro 5.2 2024 year in review What's new in Astro - December 2024 Astro 5.1 Astro 5.0 Google IDX: Our Official Online Editor Partner What's new in Astro - November 2024 What's new in Astro - October 2024 Astro x Cloudinary SDK What's new in Astro - September 2024 Community Loaders for Astro Content Layer Astro x Hygraph: Content Loader Astro x Cloudinary: Content Loader Astro x Storyblok: Content Loader Content Layer: A Deep Dive Starlight 0.28 Astro 5.0 Beta Release The $100,000 Astro Ecosystem Fund Fall Update Goodbye Studio, Hello DB What's new in Astro - August 2024 Astro 4.15 Astro 4.14 Astro 4.13 What's new in Astro - July 2024 Astro 4.12: Server Islands Netlify: Our Official Deployment Partner What's new in Astro - June 2024 Astro 4.11 Astro Together 2024 Server Islands The Astro Content Layer Zero-JavaScript View Transitions Astro 4.10 Starlight turns one year old! What's new in Astro - May 2024 Astro 4.9 Astro 4.8 What's new in Astro - April 2024 Astro 4.7 Astro 4.6 What's new in Astro - March 2024 Migrating 500+ tests from Mocha to Node.js Astro DB: A Deep Dive The Astro Developer Portal Astro DB
Astro 2.5
Matthew Phillips, Ben Holmes, Erika, Bjorn Lu · 2023-05-18 · via The Astro Blog

We just released Astro 2.5, with a big list of features including:

  • Data collections and references: Your src/content/ folder can now include JSON and YAML files to store data. You can reference this data from your other collections.
  • Hybrid rendering (experimental): Allow server routes in your mostly static sites.
  • Custom client directives (experimental): A new API for integrations to define their own loading mechanics for client: directives.
  • HTML minification: An option to allow you to minify your Astro templates.
  • Parallelized rendering: Astro now runs sibling components in parallel, speeding up rendering when you have multiple components doing their own data loading.
  • Polymorphic type helper: Define a component that accepts the same props as built-in elements.

Data collections and references

Content collections are Astro’s first-class solution to managing and authoring content. Astro 2.5 takes that story even further with new data formats and collection references.

First, we’ve introduced a new type: 'data' property to store data formats like JSON and YAML in their own collections. This unlocks using collections for new forms of content including author profiles, reusable image alt text, translation dictionaries, and more.

Create data collections alongside your existing content collections:

src/content/

blog/

week-1.md

week-2.md

authors/

grace-hopper.json

alan-turing.json

Configure them using the new type: 'data' property:

import { defineCollection, z } from "astro:content"

const authors = defineCollection({

type: "data",

schema: z.object({

name: z.string(),

socialLink: z.string().url(),

}),

})

const blog = defineCollection({

type: "content",

schema: z.object({

/* ... */

}),

})

export const collections = { blog: blog, authors: authors }

You may also want to “reference” related entries. A common example is a blog post that references reusable author profiles stored as JSON in a data collection, or related post URLs stored in the same collection. You can configure these relationships using the new reference() function:

import { defineCollection, reference, z } from "astro:content"

const blog = defineCollection({

type: "content",

schema: z.object({

title: z.string(),

// Reference a single author from the `authors` collection by `id`

author: reference("authors"),

// Reference an array of related posts from the `blog` collection by `slug`

relatedPosts: z.array(reference("blog")),

}),

})

const authors = defineCollection({

type: "data",

schema: z.object({

/** ... */

}),

})

export const collections = { blog, authors }

Now, each blog post can reference related entries with type-safe validation:

---

title: "Welcome to my blog"

author: ben-holmes # references `src/content/authors/ben-holmes.json`

relatedPosts:

- about-me # references `src/content/blog/about-me.md`

- my-year-in-review # references `src/content/blog/my-year-in-review.md`

---

Check the updated content collections guide for in-depth examples.

Static by default hybrid rendering (experimental)

In 2.0 we added the ability to pre-render individual pages in SSR apps. Now in 2.5 you can also do the opposite; in a mostly static site you can specify some routes to not be prerendered.

This new 'hybrid' server output option flips the default pre-rendering behaviour of SSR so that you no longer have to mark each and every static routes that you want pre-rendered. This option will be marked as experimental for a short period of time as we stabilize edge cases. You can use it today by enabling the hybridOutput flag in the experimental section of your config and adding an adapter:

astro.config.mjs

import { defineConfig } from "astro/config"

import nodejs from "@astrojs/node"

export default defineConfig({

output: "hybrid",

adapter: nodejs(),

experimental: {

hybridOutput: true,

},

})

Once you’ve done that, your entire site will be pre-rendered by default. You can opt out of pre-rendering by setting the prerender export of any page or endpoint to false:

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>

Custom client directives (experimental)

Custom client directives allow integration authors to define new client: directives to gain greater control over when components load.

Integrations can add these through the astro:config:setup hook’s new addClientDirective() API. To use this API, enable customClientDirectives in the experimental section of your config.

astro.config.mjs

import { defineConfig } from "astro/config"

import onClickDirective from "astro-click-directive"

export default defineConfig({

integrations: [onClickDirective()],

experimental: {

customClientDirectives: true,

},

})

astro-click-directive

export default function onClickDirective() {

return {

hooks: {

"astro:config:setup": ({ addClientDirective }) => {

addClientDirective({

name: "click",

entrypoint: "astro-click-directive/click.js",

})

},

},

}

}

Now you can use client:click on any of your framework components with full type support.

See the client directives documentation to learn how to build these types of integrations.

HTML minification

You can now opt-in to minification of the HTML produced by your Astro components.

Using the compressHTML option, Astro will remove all whitespace from your HTML including line breaks.

We wanted to enable minification without sacrificing performance. For server-rendered apps, doing minification on each render could be costly. With compressHTML your components are compressed only once by the Astro compiler, and then during the build.

You can enable this in your config:

import { defineConfig } from "astro/config"

export default defineConfig({

compressHTML: true,

})

Note: compression occurs both in development mode and in the final build.

While this option will not compress HTML produced by framework component you can write a middleware to compress HTML responses.

Parallelized rendering

Astro will now render components in parallel so that data-loading components higher in the tree will no longer block other components that are also loading data, as in the example below:

<Delayed ms={30} />

<Delayed ms={20} />

<Delayed ms={40} />

<Delayed ms={10} />

This <Delayed /> component waits a number of milliseconds. Previously, each component would need to wait for the previous to finish before it started rendering. In 2.5 these will now all render at the same time.

Fun fact: we attempted to add this optimization in the past but were lacking good benchmarks to ensure that this didn’t actually slow down rendering. Recent improvements to our benchmarking CI infrastructure has now allowed us to implement this with confidence.

Polymorphic type helper

Astro now includes a TypeScript helper (Polymorphic) to make it easier to build components that can render as different HTML elements with full type safety. This is useful for components like <Link> that can render as either <a> or <button> depending on the props passed to it.

The example below implements a fully-typed, polymorphic component that can render as any HTML element. The HTMLTag type is used to ensure that the as prop is a valid HTML element.

---

import { HTMLTag, Polymorphic } from "astro/types"

type Props<Tag extends HTMLTag> = Polymorphic<{ as: Tag }>

const { as: Tag, ...props } = Astro.props

---

<Tag {...props} />

More

Additional bug fixes and improvements are included in this release. Check out the release notes to learn more.