# why
# what
- The web framework for content-driven websites 内容驱动网站的网络框架
- 适合搭建:营销网站、播客、电子商务网站
- **Astro** 是一个 JavaScript 网络框架,针对构建快速、内容驱动的网站进行了优化。
- 服务器优先:Astro 通过在服务器上呈现组件来提高网站性能,将轻量级 HTML 发送到浏览器,且不产生任何不必要的 JavaScript 开销。
- 内容驱动:Astro 旨在处理您的内容,无论其位于何处。您可以从文件系统、外部 API 或您常用的 CMS 加载数据。
- 可定制:使用您喜爱的工具扩展 Astro。带上您自己的 JavaScript UI 组件、CSS 库、主题、集成等等。支持主流 UI 框架:react、vue
- 网站性能对比
- 
# how
## 建站所需的功能
- 内容集合content collections:使用内置的typescript类型安全和前置验证来组织您的 markdown 和 MDX。
- 默认不使用 js zero JS, by default:仅使用需要的 js,自动删除其余部分,以加快网站速度。
- 试图转换 view transitions:使用内置浏览器原生view transition API。
- 中间件 Middleware:使用自定义逻辑(身份验证、日志、记录或数据提取)包装传入的请求。
- 行动 Actions:编写类型安全的后端函数,您可以直接从前端 js 客户端代码调用。
- 环境变量 environment variables:使用内置 API 管理环境变量。
- 部署适配器:deployment adapters:添加集成以立即为 vercel、AWS 或其他托管平台不熟。
- UI 集成 UI integrations:可以集成 UI 框架和组件库。
- 开发工具栏 Dev Toolbar:使用内置开发工具栏的应用程序和集成来扩展您的开发环境。
## 生态系统
- 主题模板
## Build with AI
- astro 提供多种[[MCP]]端口,可通过与 AI对话方式进行网站构建
- 配置完成后,您可以向 AI 工具询问有关 Astro 的问题,它会直接从最新文档中检索信息。编码代理在执行编码任务时将能够查阅最新文档,而聊天机器人将能够准确回答有关 Astro 功能、API 和最佳实践的问题。
- - **Start with templates**: Rather than building from scratch, ask AI tools to start with an existing [Astro template](https://astro.build/themes/) or use `npm create astro@latest` with a template option.
**从模板开始** :无需从头开始构建,而是要求 AI 工具从现有的 [Astro 模板](https://astro.build/themes/)开始,或者使用带有模板选项的 `npm create astro@latest` 。
- **Use `astro add` for integrations**: Ask AI tools to use `astro add` for official integrations (e.g. `astro add tailwind`, `astro add react`). For other packages, install using the command for your preferred package manager rather than editing `package.json` directly.
**使用 `astro add` 进行集成** :请要求 AI 工具使用 `astro add` 进行官方集成(例如 `astro add tailwind` 、 `astro add react` )。对于其他软件包,请使用您首选的软件包管理器的命令进行安装,而不是直接编辑 `package.json` 。
- **Verify current APIs**: AI tools may use outdated patterns. Ask them to check the latest documentation, especially for newer features like sessions and actions. This is also important for features that have seen significant changes since their initial launch, such as content collections, or previously experimental features that may no longer be experimental.
**验证当前的 API** :AI 工具可能使用过时的模式。请要求他们检查最新的文档,尤其是针对会话和操作等新功能。对于自首次发布以来已发生重大变化的功能(例如内容集合)或之前处于实验阶段但可能不再处于实验阶段的功能,这一点也很重要。
- **Use project rules**: If your AI tool supports it, set up project rules to enforce best practices and coding standards, such as the ones listed above.
**使用项目规则** :如果您的 AI 工具支持,请设置项目规则来强制执行最佳实践和编码标准,例如上面列出的那些。
# how good
- 安装后
- next Liftoff confirmed. Explore your project!
- Enter your project directory using cd ./../GitHub/astro-project
- Run `npm run dev` to start the dev server. CTRL+C to stop.
- Add frameworks like react or tailwind using `astro add`.
- Stuck? Join us at https://astro.build/chat
# Ref.
- https://astro.build/
- https://docs.astro.build/en/getting-started/
- https://github.com/tansongchen/tansongchen.github.io