Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
docs: Hide "on this page" element when there are no headings (#31635)
Danilo Leal0791596cdacf
diff --git a/docs/theme/page-toc.js b/docs/theme/page-toc.jsindex 62af2e7dc43..647a3810586 100644--- a/docs/theme/page-toc.js+++ b/docs/theme/page-toc.js@@ -59,6 +59,19 @@ const updateFunction = () => {window.addEventListener("load", () => {const pagetoc = getPagetoc();const headers = [...document.getElementsByClassName("header")];++ const nonH1Headers = headers.filter(+ (header) => !header.parentElement.tagName.toLowerCase().startsWith("h1"),+ );+ const sidetoc = document.querySelector(".sidetoc");++ if (nonH1Headers.length === 0) {+ if (sidetoc) {+ sidetoc.style.display = "none";+ }+ return;+ }+headers.forEach((header) => {const link = Object.assign(document.createElement("a"), {textContent: header.text,