diff --git a/www/src/components/table-of-contents.tsx b/www/src/components/table-of-contents.tsx index 04039ca..7cdc061 100644 --- a/www/src/components/table-of-contents.tsx +++ b/www/src/components/table-of-contents.tsx @@ -8,6 +8,19 @@ import { HTMLAttributes, useCallback, useEffect } from "react" interface TableOfContentsProps extends HTMLAttributes {} +const getIndentationClass = (level: number) => { + switch (level) { + case 2: + return "pl-4" + case 3: + return "pl-8" + case 4: + return "pl-12" + default: + return "pl-4" + } +} + export const TableOfContents = ({ className, ...props @@ -38,7 +51,7 @@ export const TableOfContents = ({ return (
-

+

On this page

    @@ -46,6 +59,7 @@ export const TableOfContents = ({ const isVisible = visibleSections.some( (section) => section === slugify(heading.text), ) + const indentClass = getIndentationClass(heading.level) return (
  • @@ -62,7 +76,8 @@ export const TableOfContents = ({ />