diff --git a/.github/workflows/docs-deploy.yml b/.github/workflows/docs-deploy.yml index bcec0f0..45ee468 100644 --- a/.github/workflows/docs-deploy.yml +++ b/.github/workflows/docs-deploy.yml @@ -19,7 +19,7 @@ concurrency: cancel-in-progress: false jobs: - build: + build-library: runs-on: ubuntu-22.04 steps: - name: Checkout @@ -36,6 +36,30 @@ jobs: - name: Build library run: npm run build + - name: Upload library bundle + uses: actions/upload-artifact@v4 + with: + name: astrochart-bundle + path: dist/astrochart.js + + build-website: + needs: build-library + runs-on: ubuntu-22.04 + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: 22 + + - name: Download library bundle + uses: actions/download-artifact@v4 + with: + name: astrochart-bundle + path: dist + - name: Copy bundle to website run: cp dist/astrochart.js website/public/astrochart.js @@ -53,7 +77,7 @@ jobs: path: website/dist deploy: - needs: build + needs: build-website runs-on: ubuntu-22.04 environment: name: github-pages diff --git a/website/src/components/ChartDemo.astro b/website/src/components/ChartDemo.astro index 86c05b6..a82fd4e 100644 --- a/website/src/components/ChartDemo.astro +++ b/website/src/components/ChartDemo.astro @@ -78,7 +78,8 @@ const codeSnippet = getCodeSnippet() chartMode: mode, chartHeight: height, radixData: defaultRadixData, - transitData: defaultTransitData + transitData: defaultTransitData, + baseUrl: import.meta.env.BASE_URL }} > ;(function () { @@ -112,7 +113,7 @@ const codeSnippet = getCodeSnippet() if (window.astrochart) { // Library already loaded — init immediately initChart() - } else if (document.querySelector('script[src="/astrochart.js"]')) { + } else if (document.querySelector('script[src="' + baseUrl + 'astrochart.js"]')) { // Another instance is already loading the bundle — queue up window.__astrochartQueue = window.__astrochartQueue || [] window.__astrochartQueue.push(initChart) @@ -122,7 +123,7 @@ const codeSnippet = getCodeSnippet() window.__astrochartQueue.push(initChart) var script = document.createElement('script') - script.src = '/astrochart.js' + script.src = baseUrl + 'astrochart.js' script.onload = function () { var queue = window.__astrochartQueue || [] window.__astrochartQueue = []