01
Démarrage
Composant
Frontmatter entre ---, puis template HTML.
astro
---
const title = "Hello";
---
<h1>{title}</h1>Props
Props transmises via Astro.props.
astro
---
interface Props { name: string; }
const { name } = Astro.props;
---
<h1>Hello {name}</h1>Pages
Routage basé sur les fichiers dans src/pages/.
astro
---
// src/pages/index.astro
---
<html><body>Hello</body></html>02
Fonctionnalités
Islands
Directives client: pour l'hydratation : load, idle, visible, only.
astro
---
import Counter from "../components/Counter.tsx";
---
<Counter client:load />Routes dynamiques
getStaticPaths pour les routes SSG dynamiques.
astro
---
export async function getStaticPaths() {
return posts.map(p => ({ params: { slug: p.slug }, props: p }));
}
const post = Astro.props;
---Content Collections
Collections de contenu typées de manière sûre.
astro
---
import { getCollection } from "astro:content";
const posts = await getCollection("blog");
---Was this helpful?