From d1e814e763dd724136eda595c84f5696d7053572 Mon Sep 17 00:00:00 2001 From: Jake Toronto Date: Wed, 1 Apr 2026 10:24:36 -0600 Subject: [PATCH] Fix search broken when HTML saved with different filename The isIndexPage detection relied on window.location.pathname matching specific patterns (index.html, projects/, etc.). When the generated HTML is downloaded or saved with a different filename, the detection fails and search indexes zero items, breaking search entirely. Replace URL-based detection with DOM-based detection by checking for the .project-list container element. The check is deferred to initSearch() (which runs on DOMContentLoaded) so the DOM elements exist by the time it executes. Using .project-list rather than .project-card ensures it works even when the index has zero projects. Co-Authored-By: Claude Opus 4.6 --- claude_code_log/html/templates/components/search.html | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/claude_code_log/html/templates/components/search.html b/claude_code_log/html/templates/components/search.html index 634e2006..683999d6 100644 --- a/claude_code_log/html/templates/components/search.html +++ b/claude_code_log/html/templates/components/search.html @@ -54,9 +54,7 @@ currentMatchIndex: 0, matches: [], searchIndex: null, - isIndexPage: window.location.pathname.includes('index.html') || - window.location.pathname.endsWith('projects/') || - (!window.location.pathname.includes('.html') && window.location.pathname.endsWith('/')) + isIndexPage: null }; // DOM elements @@ -76,6 +74,9 @@ // Initialize search function initSearch() { + // Detect page type by content rather than URL so it works regardless of filename + searchState.isIndexPage = document.querySelector('.project-list') !== null; + // Build search index from page content buildSearchIndex();