-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Hide how-to-doc for Nextra v3 (#233)
- Loading branch information
Showing
4 changed files
with
32 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { useEffect, useRef } from "react"; | ||
|
||
export default function DocTitle() { | ||
const titleRef = useRef(null); | ||
|
||
useEffect(() => { | ||
if (!titleRef.current) { | ||
return; | ||
} | ||
|
||
const isDocRoute = window.location.pathname.startsWith("/how-to-doc"); | ||
const parent = titleRef.current.parentNode; | ||
const grandparent = parent.parentNode; | ||
|
||
// Hide sidebar menu option | ||
if (!isDocRoute && parent.tagName === "A" && grandparent.tagName === "LI") { | ||
grandparent.classList.add("hidden"); | ||
} | ||
|
||
// Hide nextLink on the page before "How to doc" | ||
if (!isDocRoute && parent.tagName === "A" && grandparent.tagName === "DIV") { | ||
parent.classList.add("hidden"); | ||
} | ||
}, []); | ||
|
||
return <span ref={titleRef}>How to doc</span>; | ||
} |
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