From 9a3122745d6647dbb9db0ded3a90729be07c9ddc Mon Sep 17 00:00:00 2001 From: overcuriousity Date: Sun, 10 Aug 2025 18:49:45 +0200 Subject: [PATCH] knowledgebase share button --- src/components/ToolFilters.astro | 9 +---- src/components/ToolMatrix.astro | 2 +- src/env.d.ts | 3 ++ src/layouts/BaseLayout.astro | 50 +++++++++++++++++++++++++--- src/pages/api/ai/query.ts | 2 +- src/pages/api/search/semantic.ts | 3 +- src/pages/index.astro | 2 -- src/pages/knowledgebase.astro | 24 +++++++++++-- src/pages/knowledgebase/[slug].astro | 18 ++++++++++ 9 files changed, 91 insertions(+), 22 deletions(-) diff --git a/src/components/ToolFilters.astro b/src/components/ToolFilters.astro index 8a79f88..1ee5008 100644 --- a/src/components/ToolFilters.astro +++ b/src/components/ToolFilters.astro @@ -771,35 +771,28 @@ const sortedTags = Object.entries(tagFrequency) btn.addEventListener('click', () => { const view = btn.getAttribute('data-view'); - // Update active states elements.viewToggles.forEach(b => { b.classList.toggle('active', b.getAttribute('data-view') === view); }); - // Call the global switchToView function if (window.switchToView) { window.switchToView(view); } else { console.error('switchToView function not available'); } - // Dispatch view changed event window.dispatchEvent(new CustomEvent('viewChanged', { detail: view, triggeredByButton: true })); - // Handle filtering after view switch setTimeout(() => { if (view === 'matrix') { - // Ensure matrix gets populated by triggering filter filterTools(); } else if (view === 'grid') { - // Standard filtering for grid view filterTools(); } - // AI view doesn't need filtering from here - }, 100); // Slightly longer delay to ensure view switch completes + }, 100); }); }); diff --git a/src/components/ToolMatrix.astro b/src/components/ToolMatrix.astro index 40c42ad..059e9d4 100644 --- a/src/components/ToolMatrix.astro +++ b/src/components/ToolMatrix.astro @@ -789,7 +789,7 @@ domains.forEach((domain: any) => { }); window.addEventListener('toolsFiltered', (event) => { - const { tools: filtered, semanticSearch } = event.detail; // ✅ Correct destructuring + const { tools: filtered, semanticSearch } = event.detail; const currentView = document.querySelector('.view-toggle.active')?.getAttribute('data-view'); if (currentView === 'matrix') { diff --git a/src/env.d.ts b/src/env.d.ts index 26358c4..8bd00b4 100644 --- a/src/env.d.ts +++ b/src/env.d.ts @@ -39,6 +39,9 @@ declare global { toggleAllScenarios?: () => void; showShareDialog?: (shareButton: Element) => void; modalHideInProgress?: boolean; + + shareArticle: (button: HTMLElement, url: string, title: string) => Promise; + shareCurrentArticle: (button: HTMLElement) => Promise; } } diff --git a/src/layouts/BaseLayout.astro b/src/layouts/BaseLayout.astro index 8c69151..404d19b 100644 --- a/src/layouts/BaseLayout.astro +++ b/src/layouts/BaseLayout.astro @@ -22,18 +22,15 @@ const { title, description = 'ForensicPathways - A comprehensive directory of di \ No newline at end of file diff --git a/src/pages/knowledgebase/[slug].astro b/src/pages/knowledgebase/[slug].astro index 312bce7..7654e8b 100644 --- a/src/pages/knowledgebase/[slug].astro +++ b/src/pages/knowledgebase/[slug].astro @@ -47,6 +47,8 @@ const hasValidProjectUrl = displayTool && displayTool.projectUrl !== undefined & displayTool.projectUrl !== null && displayTool.projectUrl !== "" && displayTool.projectUrl.trim() !== ""; + +const currentUrl = Astro.url.href; --- @@ -77,6 +79,22 @@ const hasValidProjectUrl = displayTool && displayTool.projectUrl !== undefined & )} 📖 +