コンテンツ管理

ウェブサイトは、サーバーサイド API クライアント (src/lib/strapi.ts) を通じて Strapi v5 ヘッドレス CMS からコンテンツを取得します。すべてのデータ取得は、ビルド時またはリクエスト時に Incremental Static Regeneration (60秒間隔の再検証) で実行されます。

Strapi API クライアント

クライアントは src/lib/strapi.ts に配置されており、各コンテンツタイプに対応する型付き関数を提供します。すべてのリクエストにはパブリックフィルター(filters[publishTarget][$contains]=public)が自動的に付与され、公開済みの一般向けコンテンツのみが配信されます。

設定

変数

説明

STRAPI_URL

Strapi ベース URL(デフォルト:http://localhost:1337

REVALIDATE

ISR 間隔(秒単位、ハードコード値:60)

PUBLIC_FILTER

すべてのクエリに自動的に適用

利用可能な関数

ページ:

  • fetchNavPages(locale) --- showInNav=true のページを sortOrder 順で取得

  • fetchPublicPages(locale) --- すべての公開ページを取得

  • fetchPublicPage(slug, locale) --- スラッグで単一ページを取得

記事:

  • fetchPublicArticles(page, pageSize, locale, categorySlug?, tagSlug?) --- オプションフィルター付きのページネーション記事一覧

  • fetchPublicArticle(slug, locale) --- スラッグで単一記事を取得

  • fetchFeaturedArticles(locale, limit?) --- 注目記事を取得

カテゴリとタグ:

  • fetchCategories(locale?) --- すべてのカテゴリを sortOrder 順で取得

  • fetchTags() --- すべてのタグを名前順で取得

メディアコレクション:

  • fetchPublicMediaCollections(page, pageSize, locale)

  • fetchPublicMediaCollection(slug, locale)

ヘルパー:

  • strapiMediaUrl(media) --- 絶対または相対メディア URL を解決

コンテンツタイプ

すべての型は src/lib/types.ts で定義されています。

記事 (Article)

フィールド

説明

title

string

記事タイトル

slug

string

URL スラッグ(ロケールごとに一意)

summary

string?

一覧ページ用の短い説明

content

string

完全な Markdown 本文

coverImage

StrapiMedia?

アイキャッチ画像

author

Author?

著者リレーション

category

Category?

単一カテゴリリレーション

tags

Tag[]

多対多タグリレーション

publishTarget

string[]

可視性(["public"]

featured

boolean

注目セクションに表示

locale

string

コンテンツロケール(enzh-CNja

publishedAt

string?

ISO 形式の公開日

ページ (Page)

フィールド

説明

title

string

ページタイトル

slug

string

URL スラッグ(例:home

metaDescription

string?

SEO メタディスクリプション

sections

Section[]

ダイナミックゾーン(Hero、FeatureGrid など)

publishTarget

string[]

可視性

sortOrder

number

ナビゲーション順序

showInNav

boolean

ナビバーに表示

locale

string

コンテンツロケール

カテゴリ、タグ、著者

  • Category --- nameslugdescriptionsortOrder、ローカライゼーション

  • Tag --- nameslug

  • Author --- namebioavatarkeycloakUserId

CMS 駆動のページ

Strapi から取得したページは**ダイナミックゾーン**パターンを使用します。各ページには sections 配列があり、各エントリにはレンダリングする React コンポーネントを識別する __component 文字列が含まれています。SectionRenderer コンポーネントがそれに応じてディスパッチします:

// src/components/sections/SectionRenderer.tsx
const componentMap = {
  "page-sections.hero": HeroSection,
  "page-sections.feature-grid": FeatureGridSection,
  "page-sections.rich-text": RichTextSection,
  "page-sections.call-to-action": CallToActionSection,
  "page-sections.image-gallery": ImageGallerySection,
};

CMS が home ページを返さない場合、サイトは StaticHomePage にフォールバックします --- これは Figma でデザインされたホームページで、ヒーロー、機能紹介、パートナーロゴ、CTA セクションを含みます。