@@ -1,7 +1,7 @@
11import { useState, useEffect, useRef } from "react";
22
3−export const TableOfContents = ({ staticPosition }) => {
4− const { nestedHeadings } = useHeadingsData();
3+export const TableOfContents = ({ staticPosition, noh3s }) => {
4+ const { nestedHeadings } = useHeadingsData(noh3s);
55 const [activeId, setActiveId] = useState();
66 useIntersectionObserver(setActiveId);
77 return (
@@ -36,11 +36,12 @@ const getNestedHeadings = (headingElements) => {
3636 return nestedHeadings;
3737};
3838
39−const useHeadingsData = () => {
39+const useHeadingsData = (noh3s) => {
4040 const [nestedHeadings, setNestedHeadings] = useState([]);
4141
42+ const query = noh3s ? "h2" : "h2, h3";
4243 useEffect(() => {
43− const headingElements = Array.from(document.querySelectorAll("h2, h3"));
44+ const headingElements = Array.from(document.querySelectorAll(query));
4445
4546 const newNestedHeadings = getNestedHeadings(headingElements);
4647 setNestedHeadings(newNestedHeadings);