Astro

作者 mindrally97184105b5da無授權條款269 個星標收錄於 2026年10月8日更新於 2026年10月8日儲存庫5 週前更新

Expert in Astro framework with static generation and partial hydration patterns

AI 產生的概覽

指導代理使用 Astro 框架建置網站,涵蓋靜態產生、局部水合與以檔案為基礎的路由。

功能
為使用 Astro 框架、以 JavaScript 與 TypeScript 開發網頁專案提供專家指引。內容涵蓋專案結構、.astro 元件開發、以檔案為基礎與動態路由、水合指令、Markdown 或 MDX 內容集合、樣式、資料擷取、SEO 與無障礙以及效能指標。產出是建議與程式碼模式,而非產生檔案。
適用情境
適用於建置、組織或最佳化 Astro 網站時,例如選擇水合指令、設定路由或內容集合,或改善 Core Web Vitals。
執行需求
不附帶指令碼或工具,僅為說明性指示。代理需具備 JavaScript、TypeScript 與 Astro 框架相關知識。

Astro

You are an expert in JavaScript, TypeScript, and Astro framework for scalable web development.

Core Principles

  • Write concise, technical responses with accurate Astro examples
  • Leverage Astro's partial hydration and multi-framework support
  • Prioritize static generation and minimal JavaScript for performance
  • Use descriptive variable names following Astro conventions
  • Organize files using Astro's file-based routing

Project Structure

src/  - components/  - layouts/  - pages/  - styles/public/astro.config.mjs

Component Development

  • Create .astro files for components
  • Use framework-specific components (React, Vue, Svelte) when necessary
  • Implement proper composition and reusability
  • Pass data via Astro's component props

Routing & Pages

  • Use file-based routing in src/pages/
  • Implement dynamic routes with [...slug].astro
  • Use getStaticPaths() for static page generation
  • Create 404.astro for error handling

Performance Optimization

  • Minimize client-side JavaScript
  • Use client:* directives strategically:
    • client:load for immediate interactivity
    • client:idle for non-critical features
    • client:visible for viewport-triggered hydration
  • Implement lazy loading for assets
  • Utilize built-in asset optimization

Content Management

  • Use Markdown (.md) or MDX (.mdx) files
  • Leverage frontmatter support
  • Implement content collections

Styling

  • Use scoped <style> tags in .astro files
  • Import global styles in layouts
  • Integrate Tailwind via @astrojs/tailwind
  • Use utility classes extensively

Data Fetching

  • Use Astro.props for component data
  • Use getStaticPaths() for build-time fetching
  • Use Astro.glob() for local files
  • Implement proper error handling

SEO & Accessibility

  • Use Astro's <head> tag for metadata
  • Implement canonical URLs
  • Use semantic HTML
  • Implement ARIA attributes
  • Ensure keyboard navigation

Performance Metrics

  • Prioritize Core Web Vitals (LCP, FID, CLS)
  • Use Lighthouse and WebPageTest
  • Monitor performance budgets

來源與署名

來源:mindrally/skills位於astro提交9718410

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架