fix: fix toc key problem

This commit is contained in:
p-sw 2024-06-02 07:54:16 +09:00
parent 3343957ad7
commit 158603326d

View File

@ -1,4 +1,4 @@
import { ReactNode } from "react";
import { ReactNode, Fragment } from "react";
import { type Toc } from "@stefanprobst/rehype-extract-toc";
import { useLocation } from "react-router-dom";
@ -9,9 +9,10 @@ function RecursivelyToc({ toc }: { toc: Toc }) {
<ul>
{toc.map((tocEntry) => {
return (
<>
<Fragment key={tocEntry.id}>
<li
key={tocEntry.id}
data-id={tocEntry.id}
className="text-neutral-500 data-[active='true']:text-black dark:data-[active='true']:text-white text-sm font-medium"
style={{ paddingLeft: `${tocEntry.depth - 1}rem` }}
data-active={
@ -25,7 +26,7 @@ function RecursivelyToc({ toc }: { toc: Toc }) {
{Array.isArray(tocEntry.children) && (
<RecursivelyToc toc={tocEntry.children} />
)}
</>
</Fragment>
);
})}
</ul>