diff --git a/packages/gatsby-theme-pitayan/src/components/TableOfContents/index.tsx b/packages/gatsby-theme-pitayan/src/components/TableOfContents/index.tsx index 8b50463..f5c1091 100644 --- a/packages/gatsby-theme-pitayan/src/components/TableOfContents/index.tsx +++ b/packages/gatsby-theme-pitayan/src/components/TableOfContents/index.tsx @@ -3,11 +3,9 @@ import React, { memo, useRef, useLayoutEffect, forwardRef } from "react" const Content: React.FC = forwardRef(({ items, levels, - lvlRef, + currentLevel = 1, }, ref) => { - if (lvlRef.current < levels) { - lvlRef.current++ - } else { + if (currentLevel >= levels) { return <> } @@ -17,7 +15,7 @@ const Content: React.FC = forwardRef(({ return (
  • {data.title} - {data.items && } + {data.items && }
  • ) })} @@ -34,7 +32,6 @@ const TableOfContents: React.FC = ({ }, articleRef) => { if (!items.length) return <> - const lvlRef = useRef(0) const listRef = useRef(null) const nodesMap = new Map = ({ return (
    {title}
    - +
    ) }