[Bug][Handbook] Fix invalid nested anchor tags and whitespace IDs in Handbook pages
Description
In several community handbook MDX files (such as projects/index.mdx and contribution/index.mdx), headings wrap an outer <a id="..."> tag around an <h3> that contains an inner <a href="..."> link.
Affected live pages:
- https://layer5.io/community/handbook/projects
- https://layer5.io/community/handbook/contribution
For example, in src/collections/handbook/projects/index.mdx:
<a id="Layer5"><h3 className="heading-top"><a href="https://layer5.io/"><img className="project-title-icon" src={layer5icon} alt="Layer5" /> Layer5</a></h3></a>
Why is this an issue?
- Invalid HTML & React warning: HTML5 and React prohibit nested
<a>tags (validateDOMNesting: <a> cannot appear as a descendant of <a>). Browsers automatically force-close the outer anchor, breaking the DOM hierarchy and click targets. - Whitespace in IDs: Heading IDs such as
id="Cloud Native Performance"andid="Clone your fork"contain spaces, which is invalid HTML for IDs and causes table of contents anchor jumping to misbehave.
Affected Files
src/collections/handbook/projects/index.mdxsrc/collections/handbook/contribution/index.mdx- Related handbook navigation links, where applicable
Expected Behavior
- The target IDs should be placed directly on the heading elements (e.g.
<h3 id="layer5" className="heading-top">). - Redundant outer
<a>wrapper tags should be removed. - Anchor links in the TOC frontmatter should match valid IDs without spaces, using lowercase kebab-case (e.g.
cloud-native-performance).
Proposed approach
- Move IDs onto the heading elements (lowercase kebab-case).
- Remove the redundant outer
<a>wrappers. - Update TOC frontmatter and grep the repo for references to the old IDs, updating any that are found.
- Run the dev server and verify that the
validateDOMNestingwarning is gone and every TOC link scrolls to the right heading.
I would like to work on this. Please assign it to me!
Screenshots
(Attach your screenshot of the console warning or broken anchor here)
The layer5.io website uses Gatsby, React, and GitHub Pages. Site content is found under the master branch.
- π See contributing instructions.
- π¨ Wireframes and designs for Layer5 site in Figma (open invite)
- ππΎππΌ Questions: Discussion Forum and Community Slack.
Join the Layer5 Community by submitting your community member form.
Hi @piyushtripathi9424 @tejaswiverma121-byte i would like to work on this issuse could you please assign this to me !!
Thank you @piyushtripathi9424 for assigning this issue for me ill raise the PR soon !!