01
시작하기
컴포넌트
--- 사이에 프론트매터(frontmatter)를 작성하고, 그 아래에 HTML 템플릿을 작성합니다.
astro
---
const title = "Hello";
---
<h1>{title}</h1>Props
Astro.props로 props를 전달받습니다.
astro
---
interface Props { name: string; }
const { name } = Astro.props;
---
<h1>Hello {name}</h1>페이지
src/pages/ 아래의 파일 기반 라우팅을 사용합니다.
astro
---
// src/pages/index.astro
---
<html><body>Hello</body></html>02
주요 기능
아일랜드(Islands)
하이드레이션을 위한 client: 디렉티브: load, idle, visible, only.
astro
---
import Counter from "../components/Counter.tsx";
---
<Counter client:load />동적 라우트
getStaticPaths로 동적 SSG 라우트를 만듭니다.
astro
---
export async function getStaticPaths() {
return posts.map(p => ({ params: { slug: p.slug }, props: p }));
}
const post = Astro.props;
---콘텐츠 컬렉션
타입 안전한 콘텐츠 컬렉션을 제공합니다.
astro
---
import { getCollection } from "astro:content";
const posts = await getCollection("blog");
---Was this helpful?