feat: add toc#974
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a table-of-contents (TOC) affordance to the page viewer, including a new subheader area and improved headline scrolling behavior so users can navigate to sections more easily.
Changes:
- Introduces TOC extraction + a dropdown UI for navigating headings.
- Adds a new “subheader” mount point in the main layout and moves viewer breadcrumbs/metadata into it.
- Refactors headline hash scrolling into a shared utility and adds an e2e test covering sticky-subheader hash navigation.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| ui/leafwiki-ui/src/lib/scrollToHeadline.ts | New shared helper to scroll to a headline id from a URL hash. |
| ui/leafwiki-ui/src/features/viewer/useScrollToHeadline.tsx | Uses the new shared scroll helper instead of inline logic. |
| ui/leafwiki-ui/src/layout/AppLayout.tsx | Adds a subheader root above the scrollable <main> area. |
| ui/leafwiki-ui/src/features/viewer/PageViewer.tsx | Renders breadcrumbs/metadata + TOC button into the subheader via a portal. |
| ui/leafwiki-ui/src/features/viewer/Breadcrumbs.tsx | Adds icon and improves breadcrumb accessibility labeling. |
| ui/leafwiki-ui/src/index.css | Styles for the new main column/subheader and updated viewer/breadcrumb styles. |
| ui/leafwiki-ui/src/features/preview/TocDropdownButton.tsx | New dropdown component for TOC entries and click-to-scroll. |
| ui/leafwiki-ui/src/features/preview/extractTocEntries.ts | New markdown-to-TOC parser that mirrors slugging/duplication behavior. |
| ui/leafwiki-ui/src/features/preview/rehypeLineNumber.ts | Exports slugifyHeadline so TOC extraction can share slug logic. |
| ui/leafwiki-ui/src/features/preview/MarkdownPreview.tsx | Adds optional TOC-related props and inline TOC rendering support. |
| e2e/tests/page.spec.ts | Adds e2e test ensuring hash navigation doesn’t land under the sticky subheader. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.