0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

astroを使ってドキュメントを書く

Posted at

概要

Astroは高速・柔軟な静的サイトジェネレーターです。Astroを使ってドキュメントサイトを作成する手順を紹介します

1. astroプロジェクトの作成

プロジェクトを作成します。元からあるテンプレートを選択することもできます。

npm create astro@latest

Starlight templateを使って作っていきます。

 astro   Launch sequence initiated.

   dir   Where should we create your new project?
         ./absolute-accretion

  tmpl   How would you like to start your new project?
         Use docs (Starlight) template

  deps   Install dependencies?
         Yes

   git   Initialize a new git repository?
         Yes

今回はabsolute-accretionというプロジェクト名で生成されたので移動します。

cd absolute-accretion

npm installします。

npm install

2. サーバー起動

現在の状態で一度開いて見ます。

npm run dev

開くとこのようになっています。
{132C5FB5-68DB-4104-8AA8-CBF7BD194AB6}.png

静的サイトで利用する際などはnpm run buildすると、distフォルダ以下にコンテンツが作成されるので展開して利用しましょう。

3. 編集

基本的にはcontent/docsの中身を編集していきます。
{CC497AE1-DC74-4D01-A500-DDE3C1330908}.png

Welcome to Starlightという文字列を変更してみたいと思います。

index.mdxのタイトルをAstroドキュメントへようこそ!に変更して保存します。
{22A6BFE4-0AD1-4188-A834-D0216478C225}.png

そうすると文字列がタイトルが変更されました。保存した瞬間反映されます。
{E7E68EE6-07EE-4444-88CC-047242652C94}.png

ドキュメントの中身を編集するにはguides,referenceのフォルダ内を編集します。
フォルダ名は任意です。はじめにページを作るときはintroductionフォルダなどにするとよいと思います。
{C001A6EA-47AA-45E9-B853-35E42105782F}.png
{62A6B8CF-DA27-417E-B28D-58743D850ADE}.png

astro.config.mjsのlabelを変更するとサイドバーの表示が変更されます。
{6B329B9F-4F6A-4D06-91DE-8712BDC0101F}.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?