astroflare
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAstroflare
Astroflare
Expert guidance for TypeScript, Tailwind, and Astro framework for scalable web development on the Cloudflare platform.
针对在Cloudflare平台上进行可扩展Web开发的TypeScript、Tailwind和Astro框架的专业指南。
Key Principles
核心原则
- Write concise, technical responses with accurate Astro examples
- Prioritize static generation and server-side islands with minimal JavaScript
- Use descriptive variable names and follow Astro's naming conventions
- NEVER change the site output without explicit user confirmation - issues are likely elsewhere in configuration, environment variables, or build process
- Organize files using Astro's file-based routing system
- Native over frameworks: Prefer native HTML elements (,
<dialog>) and web components over framework-specific solutions when possible. Use framework features only when they provide clear value.<form>
- 撰写简洁、技术准确的回复,并附带正确的Astro示例
- 优先选择静态生成和服务端孤岛(Server-side Islands),尽量减少JavaScript使用
- 使用描述性变量名,遵循Astro的命名规范
- 未经用户明确确认,绝不修改站点输出 - 问题可能出在配置、环境变量或构建流程的其他环节
- 使用Astro的基于文件的路由系统组织文件
- 原生优先于框架:尽可能使用原生HTML元素(如、
<dialog>)和Web组件,而非框架特定方案。仅当框架功能能提供明确价值时才使用。<form>
Project Architecture
项目架构
Deployment Target
部署目标
- Cloudflare Workers with and component server islands for server-side rendering
output: 'static' - Use directive for server islands to optimize performance
server:defer - Cloudflare adapter configured with platformProxy for forms/server actions
- Trailing slashes always () to match Cloudflare Workers behavior
trailingSlash: 'always'
- 采用和组件服务端孤岛实现服务端渲染的Cloudflare Workers
output: 'static' - 为服务端孤岛使用指令以优化性能
server:defer - 配置Cloudflare适配器并启用platformProxy以支持表单/服务端操作
- 始终保留尾部斜杠(),以匹配Cloudflare Workers的行为
trailingSlash: 'always'
Project Structure
项目结构
src/
├── components/ # Astro components and custom web elements
│ ├── core/ # Reusable core components
│ ├── forms/ # Form components with client-side logic
│ ├── modals/ # Modal dialogs
│ └── animations/ # Animated components
├── layouts/ # Page layouts
├── pages/ # File-based routing
├── actions/ # Server actions (forms, API endpoints)
├── utils/ # Utility code
└── styles/ # Global stylessrc/
├── components/ # Astro组件和自定义Web元素
│ ├── core/ # 可复用核心组件
│ ├── forms/ # 包含客户端逻辑的表单组件
│ ├── modals/ # 模态对话框
│ └── animations/ # 动画组件
├── layouts/ # 页面布局
├── pages/ # 基于文件的路由
├── actions/ # 服务端操作(表单、API端点)
├── utils/ # 工具代码
└── styles/ # 全局样式Component Development
组件开发
- Create files for all components - this is the default and preferred approach
.astro - Use for reusable components
components/core/ - Prefer custom web components over React islands for interactivity
- Use native HTML elements (,
<dialog>) when possible<form>
- 所有组件均创建为文件 - 这是默认且推荐的方式
.astro - 将可复用组件放在目录下
components/core/ - 对于交互功能,优先选择自定义Web组件而非React孤岛
- 尽可能使用原生HTML元素(如、
<dialog>)<form>
Package Management
包管理
- Use pnpm as the package manager
- Node version: 24.x
- pnpm version: >=10
- 使用pnpm作为包管理器
- Node版本:24.x
- pnpm版本:>=10
References
参考资料
For detailed guidance, see:
- - Component patterns and Starwind UI
references/components.md - - Routing and pages
references/routing.md - - Forms and server actions
references/forms.md - - Tailwind CSS patterns
references/styling.md - - Comprehensive SEO guide
references/seo.md - - Testing patterns
references/testing.md - - Build and deployment
references/deployment.md
如需详细指南,请参阅:
- - 组件模式与Starwind UI
references/components.md - - 路由与页面
references/routing.md - - 表单与服务端操作
references/forms.md - - Tailwind CSS模式
references/styling.md - - 全面SEO指南
references/seo.md - - 测试模式
references/testing.md - - 构建与部署
references/deployment.md