@@ -1,4 +1,5 @@
1import { useState, useEffect, useRef } from "react";
1import { useState, useEffect, useRef } from "react";
2+import classNames from "classnames";
3export const TableOfContents = ({ staticPosition, noh3s }) => {
4export const TableOfContents = ({ staticPosition, noh3s }) => {
4 const { nestedHeadings } = useHeadingsData(noh3s);
5 const { nestedHeadings } = useHeadingsData(noh3s);
@@ -12,7 +13,9 @@ export const TableOfContents = ({ staticPosition, noh3s }) => {
13 style={{ top: "8rem", height: "calc(100vh - 16rem)" }}
14 style={{ top: "8rem", height: "calc(100vh - 16rem)" }}
16+ <div className="relative after:fixed after:bg-gradient-to-t after:from-white after:via-white after:bottom-0 after:w-52 after:h-60 after:pointer-events-none">
15− <Headings headings={nestedHeadings} activeId={activeId} />
17+ <Headings headings={nestedHeadings} activeId={activeId} />
@@ -51,11 +54,19 @@ const useHeadingsData = (noh3s) => {
53const Headings = ({ headings, activeId }) => (
56const Headings = ({ headings, activeId }) => (
58+ className={classNames({
59+ hidden: headings.length === 1 && headings?.[0]?.items?.length === 0,
55 {headings.map((heading, index) => (
62 {headings.map((heading, index) => (
56 <li key={heading.id}>
63 <li key={heading.id}>
65+ className={classNames({
66+ "font-bold": index === 0,
58− className={index === 0 ? "font-bold" : "font-medium text-sm"}
67+ "font-medium text-sm": index !== 0,
68+ "text-green-400": heading.id === activeId && index !== 0,
59 href={`#${heading.id}`}
70 href={`#${heading.id}`}
61 {heading.title}
72 {heading.title}