🤔Docusaurus とは?
Docusaurus は Meta が開発した静的サイトジェネレータです。
他の静的サイトジェネレータと比べて、以下の特徴があります。
- 豊富な採用実績
- MDX や i18n、Algolia DocSearch のサポート
フォルダー構成
このドキュメントは docs フォルダーの直下に構成されています(3階層以降は省略)。
docs/
├── docs/
│ ├── document/
│ ├── homepage/
│ ├── infra/
│ └── intro/
├── src/
│ ├── components/
│ ├── css/
│ └── pages/
├── static/
│ ├── img/
│ └── .nojekyll
├── .gitignore
├── docusaurus.config.ts
├── package.json
├── README.md
├── sidebars.ts
└── tsconfig.json
例えば、現在、表示しているこのページは docs/docs/document/01-what-is-docusaurus.md です:
デプロイ環境
このドキュメントは GitHub Pages を利用しています。
更に、ドキュメントの更新をトリガーにした以下の GitHub Actions を用いて、自動デプロイを行っています。
デプロイのテスト
name: 🌐 Test deployment
on:
pull_request:
branches: main
paths:
- "@caravan-kidstec/docs/**"
permissions:
contents: read
pull-requests: write
jobs:
test-deploy:
name: Test deployment
runs-on: ubuntu-latest
steps:
- name: 📥 Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
persist-credentials: false
- name: 🐣 Install bun
uses: oven-sh/setup-bun@735343b667d3e6f658f44d0eca948eb6282f2b76
with:
bun-version: canary
- name: 📦 Install dependencies
run: bun i --frozen-lockfile
- name: 🌐 Test build website
run: bun docs-build
GitHub Pages へデプロイ
name: 🐙 Deploy to GitHub Pages
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
push:
branches: main
paths:
- "@caravan-kidstec/docs/**"
jobs:
build:
name: Build Docusaurus
runs-on: ubuntu-latest
if: github.repository_owner == 'openup-labtakizawa'
permissions:
contents: read
pull-requests: write
steps:
- name: 📥 Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
persist-credentials: false
- name: 🐣 Install bun
uses: oven-sh/setup-bun@735343b667d3e6f658f44d0eca948eb6282f2b76
with:
bun-version: canary
- name: 📦 Install dependencies
run: bun i --frozen-lockfile
- name: 🧩 Build website
run: bun docs-build
- name: 🆙 Upload Build Artifact
uses: actions/upload-pages-artifact@v4
with:
path: "@caravan-kidstec/docs/build"
deploy:
name: Deploy to GitHub Pages
needs: build
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: 🐙 Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
詳細は Docusaurus のドキュメントを参考にして下さい。