Skip to content

i18n(ja): Add guides/migrate-to-astro/from-gitbook.mdx #11700

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions src/content/docs/ja/guides/migrate-to-astro/from-gitbook.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
title: GitBookからの移行
description: GitBookプロジェクトをAstroに移行するためのガイド
sidebar:
label: GitBook
type: migration
stub: true
framework: GitBook
i18nReady: true
---
import PackageManagerTabs from '~/components/tabs/PackageManagerTabs.astro'

[GitBook](https://gitbook.com)は、バージョン管理とカスタマイズ機能を備えたドキュメント、書籍の共同執筆プラットフォームです。

## GitBookとAstroの類似点

GitBookとAstroには、プロジェクト移行を容易にするいくつかの共通点があります。

- どちらも[Markdown](/ja/guides/markdown-content/)をサポートしています。GitBookの**GitSync**機能を使えば、既存ドキュメントをそのまま移行できます。
- どちらも何らかの[ファイルベースルーティング](/ja/guides/routing/)を採用しています。Astroのディレクトリ構造で既存コンテンツを管理しても違和感は少ないでしょう。

## GitBookとAstroの主な相違点

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ここに英語版ではWhen you migrate your GitBook docs to Astro, you will notice some important differences:とあるのでここも翻訳を含めた方が良いと思います。下の翻訳は軽く翻訳したものなので完璧ではないですがぜひ追加する際に参考にしてみてください:

GitBook DocsからAstroへ移行する際以下の重要な違いがあります。

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
GitBook DocsからAstroへ移行する際以下の重要な違いがあります。

- GitBookサイトはオンラインダッシュボードで編集します。Astroでは[コードエディタ](/ja/editor-setup/)とローカル/クラウドの開発環境でサイトを管理します。
- GitBookはコンテンツをデータベースに保存します。Astroでは各ページをMarkdownやMDXなど**個別ファイル**として[`src/`ディレクトリ](/ja/basics/project-structure/)に配置します。あるいは[CMS](/ja/guides/cms/)と連携してデータを取得することもできます。
- GitBookはMarkdown上に独自構文を追加しています。Astroでは類似構文を持つMarkdocを[Markdocインテグレーション](/ja/guides/integrations-guide/markdoc/)で利用できます。

## GitBookサイトをAstroに変換する

GitBookドキュメントサイトをAstroへ移行するには、まず[公式Starlightドキュメントテーマ](https://starlight.astro.build)スターターを使用するか、[テーマショーケース](https://astro.build/themes?search=&categories%5B%5D=docs)でコミュニティ製ドキュメントテーマを探してください。

`create astro`コマンドに`--template`を渡すと、公式スターターで新しいAstroプロジェクトを作成できます。また、[GitHub上の既存Astroリポジトリから新規プロジェクトを開始](/ja/install-and-setup/)することも可能です。

<PackageManagerTabs>
<Fragment slot="npm">
```shell
npm create astro@latest -- --template starlight
```
</Fragment>
<Fragment slot="pnpm">
```shell
pnpm create astro@latest --template starlight
```
</Fragment>
<Fragment slot="yarn">
```shell
yarn create astro --template starlight
```
</Fragment>
</PackageManagerTabs>

Astroプロジェクトを準備したら、GitBookの[Git Sync機能](https://docs.gitbook.com/product-tour/git-sync)でコンテンツをGitHub/GitLabリポジトリへ同期し、新しいAstroリポジトリに取り込みます。

テンプレートのコンテンツコレクションに直接同期する場合は、`src/content/docs/en`または`src/content/docs`を同期先ディレクトリに指定してください。

同期完了後、AstroリポジトリにGitBookのコンテンツがコピーされます。今後の衝突を防ぐため、GitSyncは無効化してください。

:::caution
GitSyncを有効にするときは、必ず優先度を**"GitBook→GitHub"**に設定してください。これによりGitBookのコンテンツがGitHubリポジトリへ同期され、誤って上書きするリスクを防げます。
:::

ただし、コンテンツをコピーしただけではそのままAstroで利用できません。GitBook特有の構文をAstro互換へ手動で変換する必要があります。

- Astroの[Markdocインテグレーション](/ja/guides/integrations-guide/markdoc/)を使用する場合、拡張子を`.mdoc`に変更します。`.md`や`.mdx`と競合しないための措置です。
- GitBookのクローズタグ記法(`{/tag}`)はMarkdocでは`{%endtag%}`となるため、ファイル全体で修正します。
- GitBook特有のコンポーネントはAstroに存在しないため、[Markdocの`tags`設定](/ja/guides/integrations-guide/markdoc/#use-astro-components-as-markdoc-tags)で独自タグとして登録するか、ファイルから削除します。

## コミュニティリソース

:::note[リソースを共有しませんか?]
GitBookサイトをAstroへ変換する際に役立つ動画やブログ記事を見つけた(または作成した)場合は、このリストにぜひ追加してください。[こちらからPRを送れます](https://github.com/withastro/docs/edit/main/src/content/docs/ja/guides/migrate-to-astro/from-gitbook.mdx)。
:::