fix: fix toc key problem
This commit is contained in:
parent
3343957ad7
commit
158603326d
@ -1,4 +1,4 @@
|
|||||||
import { ReactNode } from "react";
|
import { ReactNode, Fragment } from "react";
|
||||||
import { type Toc } from "@stefanprobst/rehype-extract-toc";
|
import { type Toc } from "@stefanprobst/rehype-extract-toc";
|
||||||
import { useLocation } from "react-router-dom";
|
import { useLocation } from "react-router-dom";
|
||||||
|
|
||||||
@ -9,9 +9,10 @@ function RecursivelyToc({ toc }: { toc: Toc }) {
|
|||||||
<ul>
|
<ul>
|
||||||
{toc.map((tocEntry) => {
|
{toc.map((tocEntry) => {
|
||||||
return (
|
return (
|
||||||
<>
|
<Fragment key={tocEntry.id}>
|
||||||
<li
|
<li
|
||||||
key={tocEntry.id}
|
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"
|
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` }}
|
style={{ paddingLeft: `${tocEntry.depth - 1}rem` }}
|
||||||
data-active={
|
data-active={
|
||||||
@ -25,7 +26,7 @@ function RecursivelyToc({ toc }: { toc: Toc }) {
|
|||||||
{Array.isArray(tocEntry.children) && (
|
{Array.isArray(tocEntry.children) && (
|
||||||
<RecursivelyToc toc={tocEntry.children} />
|
<RecursivelyToc toc={tocEntry.children} />
|
||||||
)}
|
)}
|
||||||
</>
|
</Fragment>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</ul>
|
</ul>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user