Skip to content

Add a switch to open and close the page TOC - #108

Merged
cyc6221 merged 2 commits into
mainfrom
page-toc-switch
Nov 4, 2026
Merged

cyc6221 merged 2 commits into
mainfrom
page-toc-switch

Conversation

@cyc6221

@cyc6221 cyc6221 commented Nov 4, 2026

Copy link
Copy Markdown
Owner

Summary

  • Switch: the $ CONTENTS title is now a button with a [-] / [+] marker. Closing the panel shrinks it to [+], and the content widens from 780px to 1058px at a 1366px viewport.
  • Saved state: the choice is stored in localStorage and applies across pages. A small script in <head> sets html.toc-closed before first paint, so the sidebar does not flash on load.
  • Reading position: the content rewraps when its width changes, so the click handler corrects the scroll offset against the top visible block.
  • Narrow screens: under 900px the TOC starts closed when no state is saved. An open TOC stacks above the content, because the fixed 280px column left about 30px for the content on a phone.

Pages without the TOC (toc: false) are unchanged.

Verification

  • bundle exec jekyll build succeeds.
  • Tested the built site in Edge on the Legendre's Conjecture note, with no JS errors:
    • Open, close and reload keep the expected state.
    • Enter toggles the switch.
    • A block near the top of the viewport moved less than 1px after toggling mid-page.
    • At 390px the TOC starts closed, and when opened the content stays 350px wide.

Known issue, not addressed here

At 390px the header nav still overflows and causes horizontal scrolling. This comes from the header, not this change.

🤖 Generated with Claude Code

cyc6221 and others added 2 commits November 4, 2026 23:45
The $ CONTENTS title is now a button. Closing the panel shrinks it to a
[+] switch and gives the content the full width. The state is saved in
localStorage and applied before first paint, and the reading position is
kept when the content rewraps. Screens under 900px start closed when no
state is saved.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The fixed 280px column left about 30px for the content on a phone, so
opening the TOC there made the page unreadable.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 4, 2026 15:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@cyc6221
cyc6221 merged commit d7551d2 into main Nov 4, 2026
1 check passed
@cyc6221
cyc6221 deleted the page-toc-switch branch November 4, 2026 19:29
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