为什么选 Astro?
[!info] Astro 的核心优势
- 默认零 JS 输出
- 支持多框架组件(React、Vue、Svelte)
- 出色的内容集合(Content Collections)
- 极快的构建速度
项目初始化
npm create astro@latest my-site
cd my-site
npm install
配置内容集合
import { defineCollection, z } from "astro:content";
const notes = defineCollection({
schema: z.object({
title: z.string(),
date: z.date(),
tags: z.array(z.string()).default([]),
}),
});
export const collections = { notes };
创建你的第一篇笔记
在 src/content/notes/ 目录下创建 markdown 文件,添加 frontmatter:
---
title: "我的第一篇笔记"
date: 2026-06-13
tags: ["入门"]
---
相关笔记:[[移动端适配指南]] · [[你好,这是我的数字花园]]