ContentManager(コンテンツマネージャー)
走査済みのエントリを完成したマニフェストに変えるコンポーネントです。公開先を解決し、Markdownとプラグインのパイプラインを実行し、コンテンツグラフとクエリ用のインデックスを構築します。
責務
- 各エントリの公開先を解決する。
- 各エントリにMarkdownとプラグインのパイプラインを実行する。
- コンテンツグラフとコンテンツインデックスを構築する。
- マニフェストを組み立て、診断を集める。
処理の順序
公開先の解決を最初に行うため、後続のフックとページは安定したパーマリンクを前提にできます。その後で処理、グラフの順に進み、最後にマニフェストを確定します。
行わないこと
ContentManagerはファイルを読みません。それはContentSourceの役割です。
ContentManagerの型
ContentManagerクラス(packages/core/src/content/content_manager.ts)は中核となるオーケストレーターです。主なメソッドは次のとおりです。
getManifest()— すべての公開先を解決し、プラグインのパイプラインを実行し、コンテンツグラフを構築して、完全なContentManifestを組み立てて返すgetContentLocations()— 各slugを解決済みの公開先(slug、permalink、リダイレクト、メタデータ)へ対応付けるReadonlyMap<string, ContentPublicLocation>を返すgetContentGraph()— 被リンク・発リンク・隣接リンクを問い合わせるContentGraphを返すgetBacklinks(targetSlug)— 指定したエントリへのバックリンクを返すinspect()— エントリ、コンテンツインデックス、診断を持つContentInspectionを返すgetPagePaths()とgetPageRoutes()— 宣言されたプラグインページのパスとルートを返す
getManifest()で見えるマニフェストエントリの抜粋例:
{
slug: "notes/hello",
permalink: "/docs/notes/hello/",
contentId: "abc123",
frontmatter: { id: "abc123", title: "Hello", tags: [] },
publishing: { routable: true, discoverable: true, status: "published" },
html: "<p>Hello world</p>",
tags: [],
links: [],
backlinks: [],
assets: [],
}
ContentManagerは内部で次のコンポーネントを調整します。
ContentIndexBuilder(packages/core/src/content/content_index_builder.ts)— slugの異形と曖昧さを解決するContentLocationResolver— プラグインが調整したパスを含む公開先を解決するPluginRuntime(packages/core/src/plugin/plugin_runtime.ts)— プラグインのフック(onContentLoaded、extendContentGraph、onManifestCreatedなど)を実行するContentBuildCoordinator— 増分ビルドの状態と出力の変更検知を管理する