Skip to content

fix: avoid TOC anchors being hidden by header#469

Merged
OXeu merged 2 commits into
release/v0.3.0from
fix/issue-220-toc-offset-v0.3.0
Mar 8, 2026
Merged

fix: avoid TOC anchors being hidden by header#469
OXeu merged 2 commits into
release/v0.3.0from
fix/issue-220-toc-offset-v0.3.0

Conversation

@OXeu
Copy link
Copy Markdown
Collaborator

@OXeu OXeu commented Mar 8, 2026

Summary

  • measure the rendered header height and expose it as a global scroll offset
  • apply that offset to markdown heading anchors and TOC click scrolling
  • keep anchor jumps and TOC jumps aligned across header layouts

Closes #220

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c2e5cacd45

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 313 to +315
{...props}
className="text-2xl font-bold mt-4"
style={{ ...props.style, scrollMarginTop: "var(--header-scroll-offset, 7rem)" }}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve markdown-provided heading classes

Rendering each heading with {...props} followed by a fixed className drops any class attributes coming from markdown (via rehypeRaw) or remark/rehype plugins, because the hardcoded class now overwrites props.className. This is a behavior change introduced in this commit that can break documents relying on custom heading classes for styling or JS hooks; merge props.className with the default classes instead of replacing it.

Useful? React with 👍 / 👎.

@OXeu OXeu merged commit 7c8f2e3 into release/v0.3.0 Mar 8, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 8, 2026

🧹 Preview deployment has been cleaned up.

The temporary preview environment for this PR has been deleted.

@OXeu OXeu deleted the fix/issue-220-toc-offset-v0.3.0 branch March 12, 2026 17:56
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.

1 participant