From 17708f1430fd63e9350af82abe40a7dd78b15b8c Mon Sep 17 00:00:00 2001 From: Elizabeth Hunt Date: Sun, 14 Dec 2025 17:08:26 -0800 Subject: Simplify host asset bundling --- src/ts/script.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/ts') diff --git a/src/ts/script.ts b/src/ts/script.ts index e0b0b85..56c6d63 100644 --- a/src/ts/script.ts +++ b/src/ts/script.ts @@ -4,6 +4,20 @@ import 'prismjs/components/prism-css'; import 'prismjs/components/prism-markup'; import { initOneko } from './oneko'; +// Auto-detect asset base from the bundled script's origin +(() => { + window.ASSET_BASE = ''; + const bundleScript = document.querySelector('script[src*="bundle"]'); + if (bundleScript?.src) { + try { + const url = new URL(bundleScript.src, window.location.href); + window.ASSET_BASE = url.origin; + } catch { + // Fall back to empty string + } + } +})(); + (() => { const toggleButton = document.getElementById('theme-toggle') as HTMLInputElement; const html = document.documentElement; -- cgit v1.2.3-70-g09d2