Skip to content

feat(toc): add collapsible table of contents functionality - #112

Open
ljxme wants to merge 2 commits into
cworld1:mainfrom
ljxme:main
Open

feat(toc): add collapsible table of contents functionality#112
ljxme wants to merge 2 commits into
cworld1:mainfrom
ljxme:main

Conversation

@ljxme

@ljxme ljxme commented Nov 29, 2025

Copy link
Copy Markdown

简要描述:

  • 基本实现目录折叠功能,当标题在视图中时自动展开
  • 具有平滑过渡和自动展开行为(Maybe🤓),实在没艺术细胞😭。。。
  • 可在 site.config.ts 文件中通过 tocCollapse 来控制是否开启目录折叠功能

详见视频:

QQ20251129-225243-HD.mp4

implement toc collapse feature with smooth transitions and auto-expand behavior when headings are in view
@vercel

vercel Bot commented Nov 29, 2025

Copy link
Copy Markdown

@ljxme is attempting to deploy a commit to the cworld Team on Vercel.

A member of the Team first needs to authorize it.

@ljxme

ljxme commented Nov 29, 2025

Copy link
Copy Markdown
Author

🤔感觉实现的还是很生硬。。。,还请大佬指正

@cworld1

cworld1 commented Dec 2, 2025

Copy link
Copy Markdown
Owner

i18n那边改动较大,为避免冲突(其实是冲突解决太麻烦),先缓一缓吧。等那边合并完后这边再考虑着手处理

@vercel

vercel Bot commented Dec 2, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
astro-theme-pure Ready Ready Preview Comment Dec 2, 2025 5:55pm

@ljxme

ljxme commented Dec 2, 2025

Copy link
Copy Markdown
Author

i18n对项目改动确实大,这个pr可以缓缓(待我改个好看点的样式😇 )

@cworld1

cworld1 commented Dec 2, 2025

Copy link
Copy Markdown
Owner

更建议用 rebase)

@kkbt0

kkbt0 commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

我研究了下,借助显示阅读进度功能加的 .highlight ,css 选择器选择下没有的目录项高度边框设置为 0 也可以。

.toc-item.ps-7:not(li:has(.highlight.toc-item) li .toc-item) {
  height: 0px;
  padding: 0px;
}

或者加个动画

/* toc 自动折叠 */
li .toc-item {
  max-height: 10rem;
}

.toc-item.ps-7:not(li:has(.highlight.toc-item) li .toc-item) {
  /* height: 0px; */
  padding-top: 0rem;
  padding-bottom: 0rem;
  max-height: 0rem;
}

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.

3 participants