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

推荐订阅源

AI
AI
Cloudbric
Cloudbric
Schneier on Security
Schneier on Security
V2EX - 技术
V2EX - 技术
N
News and Events Feed by Topic
Hacker News: Ask HN
Hacker News: Ask HN
L
LINUX DO - 最新话题
V
Visual Studio Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
W
WeLiveSecurity
博客园 - 司徒正美
Jina AI
Jina AI
S
Secure Thoughts
罗磊的独立博客
Hugging Face - Blog
Hugging Face - Blog
有赞技术团队
有赞技术团队
WordPress大学
WordPress大学
Security Archives - TechRepublic
Security Archives - TechRepublic
博客园 - 三生石上(FineUI控件)
The Last Watchdog
The Last Watchdog
S
Security @ Cisco Blogs
S
SegmentFault 最新的问题
Attack and Defense Labs
Attack and Defense Labs
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
SecWiki News
SecWiki News
Google DeepMind News
Google DeepMind News
T
Troy Hunt's Blog
H
Heimdal Security Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
N
News and Events Feed by Topic
雷峰网
雷峰网
Last Week in AI
Last Week in AI
IT之家
IT之家
Project Zero
Project Zero
O
OpenAI News
腾讯CDC
The Hacker News
The Hacker News
L
Lohrmann on Cybersecurity
T
Tenable Blog
博客园_首页
C
Cisco Blogs
酷 壳 – CoolShell
酷 壳 – CoolShell
S
Schneier on Security
Scott Helme
Scott Helme
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
人人都是产品经理
人人都是产品经理
P
Privacy International News Feed
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻

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.4
Matthew Phillips · 2023-05-04 · via The Astro Blog

Astro 2.4 just dropped, and features:

  • Stronger scoping for CSS: A new opt-in flag scopedStyleStrategy allows you to configure a higher specificity for your Astro components’ scoped styles.
  • Improved <Code /> component: Upgraded Shiki and support for inlining.
  • SSR support in sitemaps: Known routes are now built into a sitemap during the build.
  • Middleware (experimental): Define code that runs before page components and endpoints, to intercept requests and modify responses.
  • CSS inlining (experimental): Allows you to configure when stylesheets should be inlined via a <style> tag.

scopedStyleStrategy

Astro uses the :where pseudo-selector for scoped Astro component styles. This approach means your component styles have the same specificity as if they were written in plain CSS. The downside of this approach is that we cannot guarantee that component styles will always override global styles, as is often expected and wanted behavior.

We’ve added the scopedStyleStrategy option which can be used to switch on a high-specificity strategy using class-based selectors:

import { defineConfig } from "astro/config"

export default defineConfig({

scopedStyleStrategy: "class",

})

This strategy will likely be used as the default in Astro 3.0.

<Code /> component improvements

The <Code /> component has a few new improvements:

  • Upgrade to Shiki 0.14 - Astro was previously on Shiki 0.11. This upgrade comes with many improvements, most notably new themes and language support.
  • New inline prop prevents a wrapping <pre> from being added. This is useful if you want syntax highlighting inline in a paragraph.

SSR in sitemaps

The @astrojs/sitemaps package has been updated to include support for server-side rendering. Previously, sitemaps were only supported when using output: 'static' because dynamic routes are unknown at build time.

The new version can now also be used with output: 'server' and will output a sitemap for known (i.e. static) routes only. Dynamic routes are excluded. No changes are needed to your configuration in order to enable this feature.

Middleware (experimental)

An early preview of middleware support has landed in 2.4. This allows you to intercept requests and responses and inject behaviors dynamically. To enable experimental middleware support, add the experimental flag in astro.config.mjs:

import { defineConfig } from "astro/config"

export default defineConfig({

experimental: {

middleware: true,

},

})

In addition to modifying the request and response, with middleware you can mutate a locals object that is available in all Astro components and API endpoints. Here’s an example of an authentication middleware. Create a src/middlware.ts file with these contents:

import type { MiddlewareResponseHandler } from "astro/middleware"

const auth: MiddlewareResponseHandler = async ({ cookies, locals }, next) => {

if (!cookies.has("sid")) {

return new Response(null, {

status: 405, // Not allowed

})

}

let sessionId = cookies.get("sid")

let user = await getUserFromSession(sessionId)

if (!user) {

return new Response(null, {

status: 405, // Not allowed

})

}

locals.user = user

return next()

}

export { auth as onRequest }

Which you can then access via your Astro components:

---

const { user } = Astro.locals

---

<h1>Hello {user.name}</h1>

This feature will remain experimental as we refine the API and fix bugs found by early adopters. See the middleware guide to learn more.

CSS inlining (experimental)

You can now configure stylesheets to be inlined into a <style> tag by enabling the experimental configuration:

import { defineConfig } from "astro/config"

export default defineConfig({

experimental: {

inlineStylesheets: "auto",

},

})

With the 'auto' option, stylesheets that are below the vite.assetInlineLimit will be added as a <style> tag rather than fetched via <link>.

You can also set the option to 'always' to force inlining. Currently, the default is 'never' but might be changed to 'auto' in Astro 3.0.

More

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