useFrontmatter() returns {} in layouts with the React adapter
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 72/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- react, typescript
- Lĩnh vực
- frontend
Hướng nghiên cứu
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 {}.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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 correctlyHello 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):MarkdownPagereturns<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 anduseContext(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
[email protected],@void/[email protected],@void/[email protected][email protected], Node.js 24, pnpm 12, macOS
- Ngôn ngữ chính
- TypeScript
- Star
- 402
- Fork
- 32
- Merge trung bình
- 12 giờ 28 phút
- Pull request đã merge (30 ngày)
- 77
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của voidzero-dev/void
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
voidzero-dev/void#478 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
voidzero-dev/void#463 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Deploy after a secret change fails for Workers over ~750 KB: source read-back capped at 1 MiBĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
voidzero-dev/void#459 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 78/100
voidzero-dev/void#428 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
voidzero-dev/void#480 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của voidzero-dev/void
Issue tương tự
-
Unsampled pageload span is profiled when profileLifecycle is 'trace' (browser UI profiling)Có thể đã có người làm @Jxxunnn đã nhận hôm nay. Đang mởBrowser Waiting for: Product Owner
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
getsentry/sentry-javascript#25497 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
e2e-failure ready-to-code
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
redhat-developer/rhdh-plugin-export-overlays#4438 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area: core
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
angular/angular#71422 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug status: needs triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
facebook/docusaurus#12739 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
factory-active task-identify-harness-labels-done task-identify-issue-type-done
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 68/100
vercel/ai#23537 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày