diff --git a/src/components/Search.astro b/src/components/Search.astro index 6b0c794..82dff35 100644 --- a/src/components/Search.astro +++ b/src/components/Search.astro @@ -234,6 +234,9 @@ const domain = Astro.url.host // Initialize with default config initSearch(); + + // Re-initialize when Astro's view transitions occur, this provides fix for SPA navigation + document.addEventListener('astro:page-load', initSearch); } \ No newline at end of file diff --git a/src/config.ts b/src/config.ts index 07d1f04..c8cd0eb 100644 --- a/src/config.ts +++ b/src/config.ts @@ -9,6 +9,7 @@ export const siteConfig = { email: 'hi@mercury.info', }, // features + spa: false, // enable single page application mode, this will enable navigation (with fade transitions) without reloading the page, and enable client-side routing noClientJavaScript: false, // disable client-side javascript, this will: // 1. disable most built-in client-side javascript from rendering (protected content component and umami still needs javascript to function, sorry) // 2. the full text search will be redirected to a search engine diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro index 055801a..e761380 100644 --- a/src/layouts/Layout.astro +++ b/src/layouts/Layout.astro @@ -19,6 +19,9 @@ interface Props { ogImage?: string; } +import { ClientRouter } from "astro:transitions"; +const spaEnabled = siteConfig.spa + const noscript = siteConfig.noClientJavaScript const statisticsEnabled = siteConfig.siteAnalytics.enabled @@ -44,6 +47,8 @@ const { title = pageTitle, author = siteConfig.defaultAuthor.name,description =