Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion site/slides/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"description": "Short intro deck for ado-aw — Continuous AI for Azure DevOps",
"scripts": {
"dev": "slidev --open",
"build": "slidev build --base ./ --out ../public/slides",
"build": "slidev build --out ../public/slides && node postbuild.mjs ../public/slides",
"export": "slidev export --wait 1500 --wait-until networkidle --output dist/ado-aw-intro.pdf"
},
"dependencies": {
Expand Down
33 changes: 33 additions & 0 deletions site/slides/postbuild.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Post-build step for the sub-path deployment of the Slidev deck.
//
// The deck is built with the default Vite base "/" so that Slidev's in-app
// navigation (getSlidePath → import.meta.env.BASE_URL) produces clean hash
// routes (/N and /presenter/N) for both play and presenter mode. JS/CSS asset
// URLs are emitted relative via experimental.renderBuiltUrl (see vite.config.ts).
//
// The only thing left pointing at an absolute "/assets/…" path is the entry
// markup in the generated HTML files. Rewrite those to "./assets/…" so the
// bundle also loads correctly when served from …/ado-aw/slides/.
import { readdir, readFile, writeFile } from 'node:fs/promises'
import path from 'node:path'

const outDir = process.argv[2]
if (!outDir) {
console.error('usage: node postbuild.mjs <out-dir>')
process.exit(1)
}

const entries = await readdir(outDir, { withFileTypes: true })
let patched = 0
for (const e of entries) {
if (!e.isFile() || !e.name.endsWith('.html')) continue
const fp = path.join(outDir, e.name)
const src = await readFile(fp, 'utf8')
const out = src.replaceAll('="/assets/', '="./assets/')
if (out !== src) {
await writeFile(fp, out)
patched++
console.log(` rewrote ${e.name}`)
}
}
console.log(`postbuild: relative-ized assets in ${patched} HTML file(s)`)
17 changes: 17 additions & 0 deletions site/slides/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { defineConfig } from 'vite'

// Deploy the deck under a sub-path (…/ado-aw/slides/) without breaking Slidev's
// in-app navigation. Slidev's getSlidePath() prepends import.meta.env.BASE_URL
// to every router target, so a non-"/" Vite base leaks into (or doubles in) the
// route path — which breaks presenter mode in particular.
//
// Fix: keep the Vite base at "/" (so BASE_URL stays "/", and hash routes resolve
// cleanly as /N and /presenter/N), but emit *relative* asset URLs via
// renderBuiltUrl so the bundle still loads correctly from the sub-path.
export default defineConfig({
experimental: {
renderBuiltUrl() {
return { relative: true }
},
},
})