Skip to content

Commit ca007b3

Browse files
afuchereca-agent
andauthored
fix(website): prefix astrochart.js path with BASE_URL (#112)
* CI: fix docs-deploy Node version for Astro build The deploy workflow ran the library build (webpack, Node 20) and the Astro website build in the same job under node-version 20, causing Astro to fail with "Node.js v20 is not supported". A single job can only run one Node version, so split the build job: - build-library (Node 20): builds the webpack bundle and uploads it as a GitHub Actions artifact - build-website (Node 22): downloads the bundle, copies it into website/public/, installs website deps, builds the Astro site, and uploads the Pages artifact - deploy: now depends on build-website (unchanged otherwise) 🤖 Generated with [eca](https://eca.dev) Co-Authored-By: eca <git@eca.dev> * fix(website): prefix astrochart.js path with BASE_URL The bundle was hard-coded as '/astrochart.js' (root-relative) in ChartDemo.astro. With base: '/AstroChart' in astro.config.mjs the file is deployed at /AstroChart/astrochart.js, so the browser was requesting the wrong path and getting a 404. Pass import.meta.env.BASE_URL into the is:inline script via define:vars and prefix both the querySelector guard and the dynamic script.src with it. Astro guarantees BASE_URL ends with '/', so concatenating 'astrochart.js' produces the correct path. 🤖 Generated with [eca](https://eca.dev) Co-Authored-By: eca <git@eca.dev> --------- Co-authored-by: eca <git@eca.dev>
1 parent e7f30e6 commit ca007b3

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

website/src/components/ChartDemo.astro

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ const codeSnippet = getCodeSnippet()
7878
chartMode: mode,
7979
chartHeight: height,
8080
radixData: defaultRadixData,
81-
transitData: defaultTransitData
81+
transitData: defaultTransitData,
82+
baseUrl: import.meta.env.BASE_URL
8283
}}
8384
>
8485
;(function () {
@@ -112,7 +113,7 @@ const codeSnippet = getCodeSnippet()
112113
if (window.astrochart) {
113114
// Library already loaded — init immediately
114115
initChart()
115-
} else if (document.querySelector('script[src="/astrochart.js"]')) {
116+
} else if (document.querySelector('script[src="' + baseUrl + 'astrochart.js"]')) {
116117
// Another instance is already loading the bundle — queue up
117118
window.__astrochartQueue = window.__astrochartQueue || []
118119
window.__astrochartQueue.push(initChart)
@@ -122,7 +123,7 @@ const codeSnippet = getCodeSnippet()
122123
window.__astrochartQueue.push(initChart)
123124

124125
var script = document.createElement('script')
125-
script.src = '/astrochart.js'
126+
script.src = baseUrl + 'astrochart.js'
126127
script.onload = function () {
127128
var queue = window.__astrochartQueue || []
128129
window.__astrochartQueue = []

0 commit comments

Comments
 (0)