Skip to content

feat: add sidebar title option#19

Merged
adkah merged 2 commits into
masterfrom
ak-sidebar-title
May 15, 2026
Merged

feat: add sidebar title option#19
adkah merged 2 commits into
masterfrom
ak-sidebar-title

Conversation

@adkah
Copy link
Copy Markdown
Contributor

@adkah adkah commented May 15, 2026

This PR adds an optional sidebarTitle field to the docs page schema. Adding this field to the frontmatter will override the page title in the sidebar.

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 15, 2026

Greptile Summary

This PR adds an optional sidebarTitle frontmatter field to both docs and API page schemas, allowing individual pages to display a shorter or different title in the sidebar without changing the page <h1> or breadcrumb text.

  • The field is correctly propagated from Zod schema → buildCollectionsSidebarData (flat map keyed by both raw id and normalized slug) → buildPages / buildSidebarTreeSidebarArticleNode → the SidebarTreeView component's node.sidebarTitle ?? node.title render.
  • Breadcrumb labels intentionally continue to use titleMap (full page title), which matches the stated scope — sidebar-only override — but this causes sidebarTitleMap to be threaded through buildBreadcrumbs and searchPagesForBreadcrumbs without ever influencing any output.

Confidence Score: 4/5

Safe to merge; the feature is narrow and well-contained, with correct fallback to the original title everywhere it is consumed.

The data pipeline is correctly wired end-to-end and the sidebar component falls back gracefully. The only rough edge is sidebarTitleMap being a required parameter in buildPages, forcing the breadcrumb functions to accept and thread a map they never actually read — a small API design issue that does not affect runtime behavior.

src/bach/tree.ts and src/bach/breadcrumbs.ts — the required sidebarTitleMap parameter creates unnecessary coupling between the breadcrumb utilities and sidebar-title data.

Important Files Changed

Filename Overview
src/bach/schemas/docs.ts Adds optional sidebarTitle field to the docs Zod schema — minimal, correct change.
src/bach/schemas/api.ts Adds optional sidebarTitle to the API collection schema, consistent with the docs schema change.
src/bach/types.ts Adds sidebarTitle?: string to SidebarArticleNode — clean type update; ArticleEntry intentionally unchanged (used for search indexing).
src/bach/content.ts Builds sidebarTitleMap from collection entries using defensive type-narrowing; both entry.id and normalized slug keyed correctly, matching the titleMap pattern.
src/bach/tree.ts Propagates sidebarTitleMap through buildPages and buildSidebarTree; parameter is required in buildPages even for callers that only need hrefs (e.g., findFirstHref).
src/bach/breadcrumbs.ts Threads sidebarTitleMap through both functions solely to satisfy the required buildPages parameter; breadcrumb labels still use titleMap (intentional), making the propagation functionally inert.
src/bach/site.ts Correctly destructures and stores sidebarTitleMap in SiteContext, and passes it to buildBreadcrumbs.
src/components/sidebar-tree-view.tsx Single-line change correctly falls back to node.title when sidebarTitle is absent.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["Frontmatter\nsidebarTitle: string"] --> B["docsSchema / apiCollectionSchema\n(Zod .optional())"]
    B --> C["buildCollectionsSidebarData\nsidebarTitleMap: Map<id|slug, sidebarTitle>"]
    B --> D["buildSidebarEntryMap\nCollectionEntryData.sidebarTitle"]
    C --> E["buildSidebarTree → buildPages\nSidebarArticleNode.sidebarTitle"]
    D --> E
    E --> F["SidebarTreeView\nnode.sidebarTitle ?? node.title"]
    C --> G["buildBreadcrumbs\n(forwarded, not used for labels)"]
    G --> H["Breadcrumb labels\nuse titleMap only"]
Loading

Comments Outside Diff (1)

  1. src/bach/tree.ts, line 65-72 (link)

    P2 Making sidebarTitleMap optional in buildPages would avoid forcing callers that only need hrefs (like the breadcrumb helper) to obtain and forward the map. Currently breadcrumbs.ts must carry sidebarTitleMap through its entire call chain purely to satisfy this required parameter, even though findFirstHref(buildPages(...)) never reads title data.

Reviews (1): Last reviewed commit: "feat: add sidebar title option" | Re-trigger Greptile

@adkah adkah merged commit ad5f316 into master May 15, 2026
6 checks passed
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.

2 participants