用 Astro 搭个人站的完整流程
为啥选 Astro
- 静态站,build 出纯 HTML,GitHub Pages 零配置
- 支持 MDX,博客可以嵌入 React/Vue 组件
- 默认零 JS,性能好
- 跟 Markdown 博客场景契合度最高
步骤
npm init -y建项目npm install astro @astrojs/mdx- 写
astro.config.mjs、src/pages/、src/content/ npm run build生成dist/- 推到 GitHub,开启 Pages 选
dist/
Content Collections
Astro 的 content collections 是核心 —— 你在 src/content/config.ts 里定义 schema,Astro 自动校验 frontmatter。