From 8a515c03b81ebdaa89069cc89d3081c8a21e9ec5 Mon Sep 17 00:00:00 2001 From: Turiiya <34311583+ttytm@users.noreply.github.com> Date: Wed, 15 May 2024 20:06:26 +0200 Subject: [PATCH] vdoc: fix search in README `index.html` when generated with `v doc -f html -m -readme` flags (#21506) --- cmd/tools/vdoc/theme/doc.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmd/tools/vdoc/theme/doc.js b/cmd/tools/vdoc/theme/doc.js index f80f6fa18a4c1c..04319f256bc49b 100644 --- a/cmd/tools/vdoc/theme/doc.js +++ b/cmd/tools/vdoc/theme/doc.js @@ -12,6 +12,9 @@ function setupScrollSpy() { const mainContent = document.querySelector('#main-content'); const toc = mainContent.querySelector('.doc-toc'); + if (!toc) { + return; + } const sections = mainContent.querySelectorAll('section'); const sectionPositions = Array.from(sections).map((section) => section.offsetTop); let lastActive = null;