Skip to content

fix: onthispage navbar component#6

Open
JVP008 wants to merge 2 commits into
Ansub:mainfrom
JVP008:fix-bug
Open

fix: onthispage navbar component#6
JVP008 wants to merge 2 commits into
Ansub:mainfrom
JVP008:fix-bug

Conversation

@JVP008
Copy link
Copy Markdown

@JVP008 JVP008 commented May 3, 2026

No description provided.

Copilot AI review requested due to automatic review settings May 3, 2026 11:21
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes the “On this page” (TOC) navigation for wiki pages by ensuring rendered markdown headings receive stable id attributes that match the TOC’s generated anchor IDs.

Changes:

  • Adjusts heading ID generation in createHeadingId (trimming and underscore normalization).
  • Adds explicit id attributes to rendered markdown h1h4 elements so TOC links can scroll correctly.
  • Updates the desktop TOC sidebar container sizing (bottom-0) to better fit the page layout.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
src/lib/markdown.ts Updates heading ID normalization used for extracted TOC headings/anchors.
src/client/routes/wiki-route.tsx Assigns IDs to rendered markdown heading elements and tweaks TOC sidebar layout.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/lib/markdown.ts
return text
.toLowerCase()
.replace(/[^\w\s-]/g, "")
.replace(/_/g, "")
Comment thread src/lib/markdown.ts
Comment on lines 135 to +141
export function createHeadingId(text: string) {
return text.toLowerCase().replace(/[^\w\s-]/g, "").replace(/\s+/g, "-");
return text
.toLowerCase()
.replace(/[^\w\s-]/g, "")
.replace(/_/g, "")
.trim()
.replace(/\s+/g, "-");
Comment on lines +27 to +32
function getTextContent(children: React.ReactNode): string {
if (typeof children === "string") return children;
if (Array.isArray(children)) return children.map(getTextContent).join("");
// @ts-ignore - children might be a ReactElement with props
if (children?.props?.children) return getTextContent(children.props.children);
return "";
Comment on lines +30 to +37
// @ts-ignore - children might be a ReactElement with props
if (children?.props?.children) return getTextContent(children.props.children);
return "";
}

const markdownComponents = {
h1: ({ ...props }) => <h1 className="mb-4 text-3xl scroll-mt-20" {...props} />,
h2: ({ ...props }) => <h2 className="font-display mb-3 mt-10 text-xl font-light scroll-mt-20" {...props} />,
h3: ({ ...props }) => <h3 className="font-display mb-2 mt-7 text-lg font-light scroll-mt-20" {...props} />,
h4: ({ ...props }) => <h4 className="mb-2 mt-5 text-base font-medium scroll-mt-20" {...props} />,
h1: ({ children, ...props }: any) => {
const id = createHeadingId(getTextContent(children));
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