feat: move TOC to sticky right sidebar for better readability#83
Conversation
jiacai2050
commented
Jan 13, 2026
- Implement side-by-side layout for content and TOC using Flexbox.
- Make TOC sticky on large screens (>= 1200px).
- Update template inheritance to use id='content' for Zine compatibility.
- Increase page max-width on wide screens to accommodate sidebar.
- Implement side-by-side layout for content and TOC using Flexbox. - Make TOC sticky on large screens (>= 1200px). - Update template inheritance to use id='content' for Zine compatibility. - Increase page max-width on wide screens to accommodate sidebar.
|
/gemini review |
There was a problem hiding this comment.
Pull request overview
This PR restructures the documentation layout by moving the Table of Contents from its original position to a sticky sidebar on the right side of the page, improving readability on larger screens. The implementation uses a responsive flexbox layout that adapts to screen size.
Changes:
- Wrap content and TOC in a flexbox container (
.content-wrapper) with sidebar positioning on screens >= 1200px - Update template inheritance pattern from
<body id="body">to<div id="content">in child templates for Zine SSG compatibility - Increase body max-width from 60vw to 80vw on large screens to accommodate the sidebar layout
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| layouts/templates/content.shtml | Restructure layout with flexbox container, move TOC to sticky sidebar, add id="content" to main content div |
| layouts/learn.shtml | Apply same flexbox layout and sidebar structure as content.shtml |
| layouts/post.shtml | Change from <body id="body"> to <div id="content"> for template inheritance compatibility |
| layouts/page.shtml | Change from <body id="body"> to <div id="content"> for template inheritance compatibility |
| layouts/monthly.shtml | Change from <body id="body"> to <div id="content"> for template inheritance compatibility |
| assets/style.css | Add responsive flexbox styles for sidebar layout with sticky positioning and increased page width on large screens |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| <a href="$if.link()"> | ||
| <span :text="$if.title"></span> | ||
| </a> | ||
| <div class="main-content"> |
There was a problem hiding this comment.
The main-content div is missing the id="content" attribute in the learn.shtml template, while it is present in content.shtml. This inconsistency could cause issues if there's JavaScript or CSS targeting the #content selector, and breaks the pattern established in content.shtml for Zine compatibility as mentioned in the PR description.
| <div class="main-content"> | |
| <div id="content" class="main-content"> |
- Change content-wrapper align-items to stretch to ensure sidebar height matches content. - Remove top margin from toc-sidebar to improve alignment. - Use top: 50% and transform: translateY(-50%) for precise vertical centering of sticky TOC.
|
这次修改主要涉及了 Flexbox 布局、定位技术 和 响应式设计 三大块 CSS 核心知识。 以下是详细的知识点拆解: 1. Flexbox 布局 (Flexible Box Layout)这是实现“左文右侧边栏”结构的基础。
2. 粘性定位 (Position Sticky)这是让 TOC 随滚动固定的核心。
3. 响应式设计 (Responsive Design)为了兼顾不同设备,使用了媒体查询。
4. 滚动行为控制
总结来说,这次修改利用 Flexbox 搭建骨架,利用 Sticky 实现交互效果,再配合 Transform 进行精细的位置调整。 |