Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 22, 2025

Floating ToC now tracks headings grouped by sections for desktop (sidebar) and mobile (toggle sheet), leaving inline 목차 untouched.

  • MDX processing: add @hbsnow/rehype-sectionize so headings have section wrappers for IntersectionObserver tracking.
  • Layout: wrap article content in a new ArticleLayout that hosts the floating ToC while preserving existing page structure.
  • ToC UX: desktop fixed sidebar, mobile floating button + sheet; ignores 목차 headings, highlights active section, collapses automatically after navigation.
  • Tests: collectHeadingInfo covers ignoring inline 목차 and section fallback.

Example heading collection:

const headings = collectHeadingInfo(document.querySelector("article")!);
// [{ id: "intro", title: "Introduction", level: 2, section: <section> }, ...]

https://github.com/user-attachments/assets/256a8b21-2f55-4361-9c83-e0bb5c20310a

Original prompt

This section details on the original issue you should resolve

<issue_title>따라다니는 목차 기능 추가</issue_title>
<issue_description>- #4 로부터 발전하기

큰 구조 변경이 필요함. 현재는 heading, 본문 등이 flat하게 되어 있는데 이를 heading으로 나눠지는 내용들로 그룹핑을 해야 함. 그렇게 해야 이 섹션을 기준으로 IntersectionObserver를 걸 수 있어서 현재 어떤 heading을 기준으로 보고 있는지가 명확해지기 때문. -> 그렇게 해야 Floating ToC에서 highlight를 할 수 있다. @hbsnow/rehype-sectionize 도구를 도입하기 (next config 수정 필요)

디자인이나 DOM 구조는 최대한 심플하게 하도록 함. (내가 추후 수정하기 쉽도록)

데스크톱일 때에는 좌측이나 우측에 Floating하게 떠있음. heading 의 개수가 아주 많을 수 있으므로 이 ToC가 screen height보다 커지는 상황도 고려해야 함.

모바일일 때에는 별도 Floating 버튼이 있고, 그 버튼을 누르면 ToC가 나오도록 하기.

Floating ToC는 SSR을 지원할 필요는 없다. 코드 구조 같은 것들도 간단하게 할 수 있으면 하기!

validation 이나 normalize는 최소화하기.

본래 본문에 삽입되던 목차는 그대로 두기.

</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@vercel
Copy link

vercel bot commented Dec 22, 2025

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

Project Deployment Review Updated (UTC)
springfall Ready Ready Preview, Comment Dec 23, 2025 11:12pm

Co-authored-by: echoja <73801151+echoja@users.noreply.github.com>
Copilot AI changed the title [WIP] Add floating table of contents feature Add floating article ToC with rehype section grouping Dec 22, 2025
Copilot AI requested a review from echoja December 22, 2025 13:13
@echoja echoja marked this pull request as ready for review December 23, 2025 22:30
@echoja echoja merged commit 76735c1 into main Dec 23, 2025
3 of 4 checks passed
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