Astro + Starlight 快速上手指南
- 安装了 Node.js(v18+)
- 有 GitHub 账号
- 会基本的命令行操作
第一步:创建项目
Section titled “第一步:创建项目”npm create astro@latest my-sitecd my-site第二步:添加 Starlight
Section titled “第二步:添加 Starlight”npx astro add starlight --yes第三步:写内容
Section titled “第三步:写内容”在 src/content/docs/ 下创建 .mdx 文件:
---title: 我的页面description: 页面描述---
这里写你的内容...第四步:本地预览
Section titled “第四步:本地预览”npm run dev打开 http://localhost:4321 查看效果。
第五步:部署
Section titled “第五步:部署”推送到 GitHub,配置 GitHub Actions 自动部署。
git add -Agit commit -m "Initial commit"git push添加暗色模式
Section titled “添加暗色模式”Starlight 自带暗色模式切换,无需额外配置。
Starlight 内置 Pagefind 搜索,构建时自动生成。
创建 src/styles/custom.css,在 astro.config.mjs 中引用:
starlight({ customCss: ['./src/styles/custom.css'],})更多内容请参考 Astro 官方文档 和 Starlight 文档。