Skip to content

Conversation

@luandro
Copy link
Contributor

@luandro luandro commented Oct 3, 2025

Background

Documentation pages rendered from Notion show inconsistent entries in the right sidebar table of contents. Some level 2 and level 3 headings appear while others are missing.

Findings

  • docusaurus.config.ts currently relies on the Docusaurus defaults and does not populate themeConfig.tableOfContents.
  • Notion generated Markdown sometimes emits heading levels at 2 and 3; Docusaurus requires explicit configuration to treat them uniformly.
  • A previous worktree (worktrees/fix-toc-inconsistency/docusaurus.config.ts) demonstrates that setting tableOfContents: { minHeadingLevel: 2, maxHeadingLevel: 3 } yields consistent results.

Goal

Define global table of contents settings so that every heading at level 2 and level 3 appears in the sidebar across the site.

Acceptance Criteria

  • themeConfig.tableOfContents is declared in docusaurus.config.ts with minHeadingLevel: 2 and maxHeadingLevel: 3.
  • Verify the sidebar on "Setting up a device & maintaining it" and other Notion generated pages shows the correct level 2 and level 3 headings.
  • Confirm handmade Markdown pages keep the expected sidebar hierarchy.
  • Document any outliers that still fail so they can be tracked separately.

Testing

  • bunx prettier --write docusaurus.config.ts
  • Manual browser check of at least one Notion sourced page and one handwritten page after applying the configuration.

- Add tableOfContents config to themeConfig
- Set minHeadingLevel: 2, maxHeadingLevel: 3
- Ensures consistent H2 and H3 display across all pages
- Fixes inconsistent TOC rendering from Notion-generated content

This global configuration ensures that:
- All H2 headings appear in right sidebar TOC
- All H3 headings appear nested under H2
- Behavior is consistent regardless of content source
- No per-page frontmatter configuration needed

The TOC inconsistency was likely caused by:
- Missing global configuration (Docusaurus defaults not explicit)
- Notion-generated markdown with varying structure
- Potential heading syntax issues in generated content

Fixes #39
@luandro luandro changed the title fix(config): add global TOC configuration for consistent heading display Define global table of contents settings for consistent sidebar headings Oct 23, 2025
@digidem digidem deleted a comment from github-actions bot Oct 30, 2025
@luandro luandro closed this Oct 31, 2025
@luandro luandro reopened this Oct 31, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Oct 31, 2025

🚀 Preview Deployment

Your documentation preview is ready!

Preview URL: https://pr-44.comapeo-docs.pages.dev

This preview will update automatically when you push new commits to this PR.


Built with commit a4f4af0

@digidem digidem deleted a comment from github-actions bot Oct 31, 2025
@digidem digidem deleted a comment from github-actions bot Oct 31, 2025
@luandro
Copy link
Contributor Author

luandro commented Oct 31, 2025

Code Review Summary

What This PR Does

This PR fixes inconsistent table of contents (TOC) rendering in the documentation sidebar by:

  • Adding explicit global TOC configuration to docusaurus.config.ts
  • Setting minHeadingLevel: 2 and maxHeadingLevel: 3
  • Ensures all H2 and H3 headings appear consistently in the right sidebar
  • Resolves issues where some headings were missing from the TOC on Notion-generated pages

How It Solves the Issue

By explicitly configuring themeConfig.tableOfContents with defined heading levels, the PR ensures:

  • Docusaurus no longer relies on default heuristics which were inconsistent
  • All H2 headings will appear in the TOC
  • All H3 headings will appear nested under their parent H2
  • Consistent behavior across all pages regardless of content source

Potential Issues & Considerations

Strengths:

  • ✅ Minimal, focused change (5 lines of config)
  • ✅ Addresses root cause: missing explicit configuration
  • ✅ No side effects - only affects TOC rendering
  • ✅ Simple and maintainable

Areas to Watch:

  • ⚠️ Heading Level Validation: Need to verify that Notion-generated content consistently uses H2/H3 for the intended TOC entries. Some content might use H4+ which would be excluded.
  • ⚠️ Handwritten Pages: PR description mentions verifying handwritten pages maintain expected hierarchy - this should be manually tested
  • ⚠️ Edge Cases: Need to verify pages with only H1 or no headings, and pages with H4+ headings

Code Quality:

  • Clean, straightforward configuration change
  • Follows Docusaurus configuration patterns
  • Well-documented in the PR description with acceptance criteria

Testing:

  • Only prettier formatting applied
  • Manual browser testing recommended as noted in acceptance criteria
  • Should verify on both Notion-generated and handwritten pages

Recommendation:Approve - Simple, well-targeted fix for a configuration issue. The explicit TOC settings will ensure consistent sidebar rendering across the site.

… TOC

- Add fixHeadingHierarchy() function to normalize Notion exports
- Converts multiple H1s to H1/H2 structure for proper TOC generation
- Removes empty headings that cause rendering issues
- Comprehensive test suite with 8 new test cases (22 tests total, all passing)
- Integrates seamlessly with existing content sanitization pipeline

Complements docusaurus.config.ts TOC configuration to fix:
#39
These files should not be tracked as they're in ignored directories
and don't serve any purpose in this branch.

Related to: PR #59
@luandro luandro closed this Nov 3, 2025
@luandro luandro deleted the fix/toc-inconsistency branch November 3, 2025 01:23
@github-actions
Copy link
Contributor

github-actions bot commented Nov 3, 2025

🧹 Preview Deployment Cleanup

The preview deployment for this PR has been cleaned up.

Preview URL was: https://pr-44.comapeo-docs.pages.dev


Note: Cloudflare Pages deployments follow automatic retention policies. Old previews are cleaned up automatically.

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