Gatsby v5と
なぜMDXを使うのか
MDXは、
メリット
- コンポーネントの
埋め込み : インタラクティブな要素を 記事に 追加可能 - 型安全: TypeScriptとの
統合が 優れている - 柔軟性: Markdownの
簡潔さと Reactの 強力さを 両立
必要なパッケージ
npm install gatsby-plugin-mdx @mdx-js/react gatsby-remark-images
設定ファイル
gatsby-config.jsに
module.exports = {
plugins: [
{
resolve: `gatsby-plugin-mdx`,
options: {
extensions: [`.mdx`, `.md`],
gatsbyRemarkPlugins: [
{
resolve: `gatsby-remark-images`,
options: {
maxWidth: 1200,
},
},
],
},
},
],
};
ディレクトリ構造
content/
blog/
2025-01-15-post/
index.md
2025-01-20-post/
index.md
フロントマター
各記事の
---
title: "記事タイトル"
date: "2025-01-20"
slug: "article-slug"
tags: ["tag1", "tag2"]
description: "記事の説明"
---
検索機能の実装
FlexSearchを
gatsby-plugin-local-searchを
まとめ
Gatsbyと
次回は、