Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

useFrontmatter() returns {} in layouts with the React adapter

オープン
#451 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
72/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
react, typescript
領域
frontend

調査の方向性

Start in @void/md/dist/plugin.mjs at emitReactComponent and @void/react/dist/runtime/pages-server.mjs where layouts wrap page elements; the issue identifies the frontmatter provider and layout placement as the likely cause. Reproduce with the linked project and compare useFrontmatter() in pages/layout.tsx with the page title. Done when the layout receives the Markdown page's frontmatter and the reproduction shows its title instead of {}.

索引モデルが issue の本文から書いたものです。

説明

Describe the bug

The Markdown guide says layouts can read the current page's frontmatter with useFrontmatter() (Frontmatter Access). With @void/react, calling it from a layout that wraps a .md page returns {}.

Reproduction

https://github.com/Nkzn/void-md-layout-frontmatter-repro

pnpm install
pnpm dev   # or: pnpm build && pnpm preview

pages/layout.tsx renders JSON.stringify(useFrontmatter()) around pages/index.md (title: Hello from frontmatter).

  • Expected: layout frontmatter: {"title":"Hello from frontmatter",...}
  • Actual: layout frontmatter: {} (while <title> is correctly Hello from frontmatter)
Possible cause

The React component generated by @void/md provides the frontmatter context only around the Markdown body:

  • @void/md/dist/plugin.mjs (emitReactComponent, around L69–L115): MarkdownPage returns <FrontmatterContext.Provider value={__frontmatter}>…</FrontmatterContext.Provider>.
  • @void/react/dist/runtime/pages-server.mjs (L121): layouts are wrapped outside the page element, so they render above the provider and useContext(FrontmatterContext) falls back to {}.
Workaround

Pass the page path to the layout (e.g. one named layout per page) and read the frontmatter from @void/md/pages instead of useFrontmatter().

Versions
主要言語
TypeScript
スター
402
フォーク
32
平均マージ
13時間 14分
マージ済み PR(30日)
73

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

voidzero-dev/void のほかの issue

voidzero-dev/void の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。