feat: remove test string

This commit is contained in:
DIYgod 2023-04-25 11:26:56 +01:00
parent 57f230a23b
commit 4b4762c1bc
No known key found for this signature in database
1 changed files with 7 additions and 3 deletions

View File

@ -24,13 +24,13 @@ function getElement(id: string) {
}
function useActiveId(itemIds: string[]) {
const [activeId, setActiveId] = useState(`test`)
const [activeId, setActiveId] = useState<string | null>()
useEffect(() => {
const observer = new IntersectionObserver(
(entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
setActiveId(entry.target.getAttribute("href") || "test")
setActiveId(entry.target.getAttribute("href"))
}
})
},
@ -54,7 +54,11 @@ function useActiveId(itemIds: string[]) {
return activeId
}
function renderItems(items: TocResult["map"], activeId: string, prefix = "") {
function renderItems(
items: TocResult["map"],
activeId?: string | null,
prefix = "",
) {
return (
<ol className={prefix ? "pl-5" : ""}>
{items?.children?.map((item, index) => (