Skip to content

Commit

Permalink
added fragment link support for h1 as well
Browse files Browse the repository at this point in the history
  • Loading branch information
nage1234 committed Dec 4, 2024
1 parent 2e4c33c commit 041f1cc
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/components/PacksReadme/PacksReadme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,15 @@ function processPackUiMap(
<ReactMarkDown
remarkPlugins={[remarkGfm]}
components={{
h1: (props) => {
const headingId = props.children?.toString().replace(/\s+/g, "-").toLowerCase();
return (
<h1 id={headingId}>
{props.children}
<a href={`#${headingId}`} className="hash-link" />
</h1>
);
},
h2: (props) => {
const headingId = props.children?.toString().replace(/\s+/g, "-").toLowerCase();
return (
Expand Down

0 comments on commit 041f1cc

Please sign in to comment.