Loading...
Loading...
Compare original and translation side by side
astro.config.mjsastro.config.mjs| Topic | Reference | When to Load |
|---|---|---|
| Components | references/components.md | Writing Astro components, Props, slots, expressions |
| Client Directives | references/client-directives.md | Hydration strategies, |
| Content Collections | references/content-collections.md | Schemas, loaders, |
| Routing | references/routing.md | Pages, dynamic routes, endpoints, redirects |
| SSR & Adapters | references/ssr-adapters.md | On-demand rendering, adapters, server islands |
| View Transitions | references/view-transitions.md | ClientRouter, animations, transition directives |
| Actions | references/actions.md | Form handling, |
| Middleware | references/middleware.md | |
| Styling | references/styling.md | Scoped CSS, global styles, |
| Images | references/images.md | |
| Configuration | references/configuration.md | |
| 主题 | 参考链接 | 加载时机 |
|---|---|---|
| 组件 | references/components.md | 编写Astro组件、Props、插槽、表达式时 |
| 客户端指令 | references/client-directives.md | 水合策略、 |
| 内容集合 | references/content-collections.md | 模式、加载器、 |
| 路由 | references/routing.md | 页面、动态路由、端点、重定向相关操作时 |
| SSR与适配器 | references/ssr-adapters.md | 按需渲染、适配器、服务器孤岛相关操作时 |
| 视图过渡 | references/view-transitions.md | ClientRouter、动画、过渡指令相关操作时 |
| 动作 | references/actions.md | 表单处理、 |
| 中间件 | references/middleware.md | |
| 样式 | references/styling.md | 作用域CSS、全局样式、 |
| 图片 | references/images.md | |
| 配置 | references/configuration.md | |
rules/rules/astro-components.rule.mdrules/client-hydration.rule.mdrules/content-collections.rule.mdrules/astro-routing.rule.mdrules/astro-ssr.rule.mdrules/astro-images.rule.mdrules/astro-typescript.rule.mdrules/rules/astro-components.rule.mdrules/client-hydration.rule.mdrules/content-collections.rule.mdrules/astro-routing.rule.mdrules/astro-ssr.rule.mdrules/astro-images.rule.mdrules/astro-typescript.rule.md<Image /><Picture />Astro.props<Image /><Picture />Astro.propsclient:client:onlyserverhybridAstro.requestclient:client:onlyserverhybridAstro.request---
// Component Script (runs on server)
interface Props {
title: string;
count?: number;
}
const { title, count = 0 } = Astro.props;
const data = await fetch('https://api.example.com/data');
---
<!-- Component Template -->
<div>
<h1>{title}</h1>
<p>Count: {count}</p>
</div>
<style>
/* Scoped by default */
h1 { color: navy; }
</style>---
// Component Script (runs on server)
interface Props {
title: string;
count?: number;
}
const { title, count = 0 } = Astro.props;
const data = await fetch('https://api.example.com/data');
---
<!-- Component Template -->
<div>
<h1>{title}</h1>
<p>Count: {count}</p>
</div>
<style>
/* Scoped by default */
h1 { color: navy; }
</style>client:loadclient:idleclient:visibleclient:mediaclient:onlyclient:loadclient:idleclient:visibleclient:mediaclient:only// src/content/config.ts
import { defineCollection, z } from 'astro:content';
const blog = defineCollection({
type: 'content',
schema: z.object({
title: z.string(),
date: z.date(),
draft: z.boolean().default(false),
tags: z.array(z.string()).optional(),
}),
});
export const collections = { blog };// src/content/config.ts
import { defineCollection, z } from 'astro:content';
const blog = defineCollection({
type: 'content',
schema: z.object({
title: z.string(),
date: z.date(),
draft: z.boolean().default(false),
tags: z.array(z.string()).optional(),
}),
});
export const collections = { blog };.astroastro.config.mjs.astroastro.config.mjs