Skip to content

Starlight

Author: Takashi
  • Starlightは、Astroをベースにした高性能なドキュメントサイト構築フレームワーク
    • Markdown、MDX、マークアップでのコンテンツ作成をサポートし、高速なパフォーマンス、優れたSEO、アクセシビリティ機能を備えている
Terminal window
# Starlightインテグレーションの追加
$ npx astro add starlight
# テンプレートの使用
$ npm create astro@latest -- --template starlight
import { defineConfig } from 'astro/config';
import starlight from '@astrojs/starlight';
export default defineConfig({
integrations: [
starlight({
title: 'ドキュメントサイト名',
social: {
github: 'https://github.com/username/repo',
},
sidebar: [
{
label: 'ガイド',
items: [
{ label: '始め方', link: '/guides/getting-started/' },
],
},
],
}),
],
});
  • src/content/docs/ディレクトリにMarkdownファイル(md, mdx)を作成する
    • フロントマターを用いて、ページのタイトルなどを挿入できる
    • 見出しに関しては、h2から始めることが推奨されている
  • 以下は公式のテンプレートのsrc/content/docs/index.mdxを記載
---
title: Welcome to Starlight
description: Get started building your docs site with Starlight.
template: splash
hero:
tagline: Congrats on setting up a new Starlight project!
image:
file: ../../assets/houston.webp
actions:
- text: Example Guide
link: /guides/example/
icon: right-arrow
- text: Read the Starlight docs
link: https://starlight.astro.build
icon: external
variant: minimal
---
import { Card, CardGrid } from '@astrojs/starlight/components';
## Next steps
<CardGrid stagger>
<Card title="Update content" icon="pencil">
Edit `src/content/docs/index.mdx` to see this page change.
</Card>
<Card title="Add new content" icon="add-document">
Add Markdown or MDX files to `src/content/docs` to create new pages.
</Card>
<Card title="Configure your site" icon="setting">
Edit your `sidebar` and other config in `astro.config.mjs`.
</Card>
<Card title="Read the docs" icon="open-book">
Learn more in [the Starlight Docs](https://starlight.astro.build/).
</Card>
</CardGrid>