Skip to content

fix(page-compiler): add metadata support to breadcrumb items#107

Merged
YusukeHirao merged 7 commits intomainfrom
claude/fix-breadcrumb-metadata-VxMkx
Mar 23, 2026
Merged

fix(page-compiler): add metadata support to breadcrumb items#107
YusukeHirao merged 7 commits intomainfrom
claude/fix-breadcrumb-metadata-VxMkx

Conversation

@YusukeHirao
Copy link
Copy Markdown
Member

@YusukeHirao YusukeHirao commented Mar 23, 2026

Summary

This PR adds metadata support to breadcrumb items, allowing access to page metadata (including custom properties) within breadcrumb transformations and enabling more flexible breadcrumb customization.

closes: #106

Key Changes

  • BreadcrumbItem type enhancement: Added a generic meta property to BreadcrumbItem<M> that contains the source page's metadata, enabling access to custom metadata properties in breadcrumb items
  • Type safety improvements:
    • Made BreadcrumbItem and GetBreadcrumbsOptions generic over metadata type M
    • Updated getBreadcrumbs() function signature to properly propagate metadata types
    • Updated transformBreadcrumbItem in PageCompilerOptions to accept BreadcrumbItem<M> with metadata
  • Test coverage:
    • Added tests verifying meta property is included in breadcrumb items
    • Added test demonstrating transformItem accessing custom metadata properties (e.g., redirectUrl)
    • Added test for metadata with transformItem and baseURL combination
    • Added test for titleList compatibility with metadata-enhanced breadcrumbs
    • Added test for pages with empty titles
  • Documentation improvements:
    • Updated JSDoc comments to clarify metadata access in breadcrumb transformations
    • Added example showing how to use item.meta.redirectUrl in transformations
    • Clarified that meta is a direct reference (not a deep copy) to source page metadata

Implementation Details

  • The meta property is populated directly from sourcePage.metaData during breadcrumb creation
  • Metadata is preserved through filtering and transformation operations
  • The implementation maintains backward compatibility while enabling new use cases like conditional URL redirects based on page metadata

https://claude.ai/code/session_01F4JmMYLB4MbgSJ5rFgGQfQ

claude added 7 commits March 23, 2026 06:04
BreadcrumbItem now includes a `meta` property containing the source
page's metaData, consistent with NavNode's `meta` property. The
transformItem callback also receives the meta property, enabling
metadata-based transformations like redirect URLs.

https://claude.ai/code/session_01F4JmMYLB4MbgSJ5rFgGQfQ
- Add JSDoc noting meta is a reference, not a deep copy
- Type CompileData.breadcrumbs as BreadcrumbItem<M>[] instead of unknown
- Add generic createMockPage helper to eliminate test casts
- Add type test for custom MetaData access via transformBreadcrumbItem
- Add coverage: empty metaData, baseURL + transformItem combo, titleList compat

https://claude.ai/code/session_01F4JmMYLB4MbgSJ5rFgGQfQ
…106)

- Update transformBreadcrumbItem docs to reflect meta property and new type signature
- Add BreadcrumbItem to API Exports list in README
- Fix duplicate JSDoc block on createMockPage test helper

https://claude.ai/code/session_01F4JmMYLB4MbgSJ5rFgGQfQ
- Add @template M to all exported generic types and functions in
  breadcrumbs.ts, types.ts, and page-compiler.ts
- Add @param/@returns to ContentHook and CompilerFunction type aliases
- Fix @example blocks using old `pageCompiler()` call style to
  `createPageCompiler()()` to match current API
- Update transformBreadcrumbItem example to show meta access

https://claude.ai/code/session_01F4JmMYLB4MbgSJ5rFgGQfQ
Revert yarn.lock to match main branch. Remove tsconfig.tsbuildinfo
which should not be tracked in version control.

https://claude.ai/code/session_01F4JmMYLB4MbgSJ5rFgGQfQ
@YusukeHirao YusukeHirao changed the title Add metadata support to breadcrumb items fix(page-compiler): add metadata support to breadcrumb items Mar 23, 2026
@YusukeHirao YusukeHirao merged commit 46658ec into main Mar 23, 2026
1 check passed
@YusukeHirao YusukeHirao deleted the claude/fix-breadcrumb-metadata-VxMkx branch March 23, 2026 06:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

getBreadcrumbs: metaDataの情報がbreadcrumbアイテムに反映されない

2 participants