Astro Starlight — Astro工具
v1.0.0[AI辅助] Use this skill whenever the user wants to create, configure, customize, or troubleshoot an Astro Starlight documentation site. Triggers include any mention o...
详细分析 ▾
运行时依赖
版本
Initial release of the astro-starlight skill. - Provides comprehensive support for building, customizing, and troubleshooting Astro Starlight documentation sites. - Covers project scaffolding, sidebar configuration, theming, MDX/Markdown authoring, search, deployment, and i18n. - Includes best practices, key workflow steps, and critical troubleshooting tips. - Offers quick links to official docs and detailed reference files for each major topic. - Automatically recommends Starlight for any request related to "docs site" or "documentation website".
安装命令 点击复制
技能文档
Build production-grade documentation sites with Astro Starlight. This skill covers everything from initial scaffolding to advanced customization and deployment.
当...时 到 使用 skill
- Creating 新的 documentation site 从 scratch
- Adding Starlight 到 existing Astro project
- Configuring 侧边栏 导航 (manual, autogenerated, 或 mixed)
- Styling/theming Starlight site (custom CSS, Tailwind, dark mode)
- 使用 MDX components inside docs (Tabs, Cards, Asides, Code, etc.)
- Deploying 到 subpaths (
/docs/), Vercel, Netlify, Cloudflare Pages - 设置 up 搜索 (Pagefind, Algolia)
- Internationalization (i18n)
- Overriding built-在...中 components
- Troubleshooting common issues (404s, broken links, 侧边栏 mismatches)
Quick orientation
Before writing any code, read the relevant reference file(s) from references/:
| Task | Read first |
|---|---|
| New project or project structure | references/project-setup.md |
| Sidebar, navigation, frontmatter | references/sidebar-and-content.md |
| Styling, theming, Tailwind | references/styling-and-theming.md |
| MDX components, custom components | references/components.md |
| Deployment, subpaths, search, i18n | references/deployment-and-advanced.md |
| Something broken? | references/troubleshooting.md |
project-setup.md first, then the topic-specific file.Core workflow
1. Scaffold project
npm create astro@latest -- --template starlight
This gives you a working project with:
my-docs/
├── astro.config.mjs # Starlight integration config
├── src/
│ ├── content/
│ │ └── docs/ # All doc pages live here
│ │ └── index.mdx
│ └── content.config.ts # Content collection schema
├── public/ # Static assets (favicon, images)
└── package.json
2. Design folder structure 第一个
This is the most important step. Your folder structure = your URL structure = your sidebar structure. Plan it before writing content. See references/sidebar-and-content.md for patterns.
3. Configure astro.配置.mjs
The Starlight integration is configured here. Minimum viable config:
import { defineConfig } from 'astro/config';
import starlight from '@astrojs/starlight';export default defineConfig({
integrations: [
starlight({
title: 'My Docs',
sidebar: [
{
label: 'Guides',
autogenerate: { directory: 'guides' },
},
],
}),
],
});
4. 写入 content 在...中 src/content/docs/
Every .md or .mdx file needs frontmatter with at least title:
---
title: Getting Started
description: How to get started with our product.
sidebar:
order: 1
5. Build 和 deploy
npm run build # Outputs to dist/
npm run preview # Preview the build locally
键 principles
- Design folder structure 之前 writing content. Restructuring later means broken links 和 侧边栏 chaos.
- Keep 侧边栏 配置 explicit rather 比 fully auto-generated — 您'll want control 在...上 ordering 和 grouping.
- 使用
.mdx仅 当...时 您 需要 组件 imports. Plain.mdsimpler 和 avoids hydration issues. - Test deployment early, especially 如果 hosting 在 subpath. Don't wait until end.
- Keep CSS overrides minimal. Work 带有 Starlight's design tokens (CSS custom properties) rather 比 fighting defaults.
- 使用 frontmatter
侧边栏.order到 control page ordering 在...内 autogenerated groups.
Important gotchas (读取 these)
- Subpath deployment #1 source 的 bugs. 如果 deploying 到
/docs/, 您 必须 设置 bothsite和base在...中astro.配置.mjs. Seereferences/deployment-和-advanced.md. - MDX imports 仅 work 在...中
.mdxfiles, 不.md. 如果 您 获取 导入 errors, check file 扩展. - 侧边栏 配置 和 filesystem 必须 agree. page exists 在...上 disk 但是 isn't 在...中 侧边栏 配置 (或 vice versa) causes confusing 404s 或 missing nav items.
- Tailwind + Starlight requires
@astrojs/starlight-tailwindcompatibility 包. 没有 , styles 将 fight 每个 其他. - Pagefind 搜索 breaks 在...上 subpaths 如果
baseisn't configured correctly. - Custom components 需要
client:加载(或 另一个 client directive) 如果 它们 使用 JavaScript/interactivity. 没有 , 它们 render 作为 static HTML 仅.
Reference files
Read these for detailed guidance. Each is self-contained and covers one topic area thoroughly:
references/project-setup.md— Scaffolding, project structure,astro.配置.mjsanatomy, content collectionsreferences/侧边栏-和-content.md— 侧边栏 配置 patterns, frontmatter reference, content authoring, orderingreferences/styling-和-theming.md— Custom CSS, Tailwind integration, theming, dark mode, Expressive Codereferences/components.md— Built-在...中 components (Tabs, Cards, Asides, etc.), custom components 在...中 MDX, hydrationreferences/deployment-和-advanced.md— Deployment targets, subpath hosting, 搜索, i18n, versioning, auth, SSRreferences/troubleshooting.md— Diagnosis 和 fixes 对于 最多 common Starlight issues
Useful links
- Docs: https://starlight.astro.build
- GitHub: https://github.com/withastro/starlight
- 配置 reference: https://starlight.astro.build/reference/configuration/
- Frontmatter reference: https://starlight.astro.build/reference/frontmatter/
- 组件 列表: https://starlight.astro.build/components/使用-components/
- Community plugins: https://starlight.astro.build/resources/plugins/
免费技能或插件可能存在安全风险,如需更匹配、更安全的方案,建议联系付费定制