diff options
| author | Elizabeth Hunt <me@liz.coffee> | 2025-12-14 17:08:26 -0800 |
|---|---|---|
| committer | Elizabeth Hunt <me@liz.coffee> | 2025-12-14 17:08:26 -0800 |
| commit | 17708f1430fd63e9350af82abe40a7dd78b15b8c (patch) | |
| tree | d06bfd4ba5bdd06d4a91efa1f62f83d5c7843b7d /src | |
| parent | 613632f3a8fccb998147e46d0e751ca4afc66544 (diff) | |
| download | adelie-17708f1430fd63e9350af82abe40a7dd78b15b8c.tar.gz adelie-17708f1430fd63e9350af82abe40a7dd78b15b8c.zip | |
Simplify host asset bundling
Diffstat (limited to 'src')
| -rw-r--r-- | src/index.html | 3 | ||||
| -rw-r--r-- | src/ts/script.ts | 14 |
2 files changed, 14 insertions, 3 deletions
diff --git a/src/index.html b/src/index.html index b20e703..835f76d 100644 --- a/src/index.html +++ b/src/index.html @@ -4,9 +4,6 @@ <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Liz CSS - Framework Demo</title> - <script> - window.ASSET_BASE = 'ASSET_BASE_PLACEHOLDER'; - </script> <link rel="stylesheet" href="/bundle.css" /> <link rel="icon" href="/img/favicon.ico" /> <style> 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; |
