-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
95 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
"use client"; | ||
import Link from "next/link"; | ||
import styles from "./mdxheadings.module.scss"; | ||
import { useState, useEffect } from "react"; | ||
|
||
const MdxHeading = ({ h, id, children }) => { | ||
const [hasMounted, setHasMounted] = useState(false); | ||
const Header = h; | ||
useEffect(() => { | ||
setHasMounted(true); | ||
}, []); | ||
if (!hasMounted) { | ||
return undefined; | ||
} | ||
if (id) { | ||
return ( | ||
<Link className="heading-link" href={`#${id}`}> | ||
<Header className={styles.mdx_heading}> | ||
<a className="anchor" id={id}></a> | ||
{children} | ||
</Header> | ||
</Link> | ||
); | ||
} | ||
return <h1>{children}</h1>; | ||
}; | ||
|
||
// cycle through and make H1 - H6 heading tags to use | ||
export const MdxH1 = (props) => <MdxHeading h="h1" {...props} />; | ||
export const MdxH2 = (props) => <MdxHeading h="h2" {...props} />; | ||
export const MdxH3 = (props) => <MdxHeading h="h3" {...props} />; | ||
export const MdxH4 = (props) => <MdxHeading h="h4" {...props} />; | ||
export const MdxH5 = (props) => <MdxHeading h="h5" {...props} />; | ||
export const MdxH6 = (props) => <MdxHeading h="h6" {...props} />; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.mdx_heading:hover::before { | ||
content: "#"; | ||
position: absolute; | ||
margin-left: -1.6ch; | ||
padding-right: 0.2ch; | ||
display: inline; | ||
color: #505363; | ||
font-size: 100%; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.