Commit 39addfd
Add translatable "On this page" title to desktop table of contents (#103)
* feat(toc): add translatable 'On this page' title to desktop TOC
Add a custom TOC component that displays a translatable "On this page"
title above the table of contents on desktop. This improves consistency
with the mobile TOC dropdown which already has a title.
Changes:
- Create custom TOC wrapper component in src/theme/TOC/index.tsx
- Add "On this page" title using @docusaurus/Translate for i18n support
- Add CSS styling for .toc-heading class with theme support
- Include Portuguese translation: "Nesta página"
- Include Spanish translation: "En esta página"
The component wraps the default Docusaurus TOC and adds a styled heading
that adapts to light/dark themes.
* fix(toc): restore sticky positioning to TOC wrapper
The TOC wrapper div was missing sticky positioning, causing the TOC
to scroll away instead of remaining fixed while scrolling the page.
Changes:
- Add .toc-wrapper class to the wrapper div
- Apply position: sticky to .toc-wrapper in CSS
- Set appropriate top offset relative to navbar height
- Add max-height and overflow-y for scrollable TOC on long pages
This fixes the regression introduced in the previous commit where
wrapping the TOC component broke the default sticky behavior.
* fix(toc): add pagination-nav padding for last item focus
Add bottom padding to .pagination-nav to allow the last heading
on a page to scroll high enough to trigger the active state in
the table of contents.
Changes:
- Add 50vh padding-bottom to .pagination-nav
- Enables last TOC item to become focused/active when scrolled to
Without this padding, the page cannot scroll far enough for the
last heading to reach the scroll position required to activate
its TOC link.
* fix(spacing): balance pagination-nav padding and add footer margin
Reduce excessive bottom padding on pagination-nav and distribute
it more evenly between top and bottom. Add matching margin-bottom
to doc footer for visual balance.
Changes:
- Change pagination-nav from 50vh bottom-only to 2rem top + 20vh bottom
- Add 3rem margin-bottom to .theme-doc-footer (matching margin-top)
This provides enough space for the last TOC item to activate while
maintaining better visual balance and less excessive whitespace.
* fix(spacing): remove padding-top from pagination-nav
Remove the 2rem top padding from pagination-nav, keeping only
the bottom padding needed for last TOC item activation.
Changes:
- Remove padding-top: 2rem from .pagination-nav
- Keep padding-bottom: 20vh for TOC functionality
---------
Co-authored-by: Claude <[email protected]>1 parent 7a63eb4 commit 39addfd
File tree
4 files changed
+67
-0
lines changed- i18n
- es
- pt
- src
- css
- theme/TOC
4 files changed
+67
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
508 | 508 | | |
509 | 509 | | |
510 | 510 | | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
0 commit comments