Files
Talks/tools/site-base.mjs
T
Le Prévost-Corvellec Arnault 354c8cd9ef Add Makefile, package.json, and initial configuration for VitePress and Slidev integration
- Introduced a Makefile for streamlined commands related to building, running, and managing presentations.
- Created package.json to define project metadata, dependencies, and scripts for development and testing.
- Added .gitignore entries to exclude build artifacts and temporary files from version control.
- Included playwright.config.mjs for end-to-end testing setup with Playwright.
- Added README.md for project documentation, outlining setup instructions and development guidelines.
2026-04-11 15:59:20 +02:00

31 lines
1.1 KiB
JavaScript

/**
* Préfixe URL du site, aligné sur VitePress `base`.
* Racine : SITE_BASE=/ ou absent
* Sous-chemin (ex. GitHub Pages) : SITE_BASE=/mon-repo/
*
* En dev local (`TALKS_PORTAL_DEV=1`, ex. make run), SITE_BASE est ignoré pour
* éviter les modules .md servis en text/html (mismatch base / URLs).
* Pour tester un sous-chemin en dev : SKIP_PORTAL_DEV=1 SITE_BASE=/repo/ npm run dev:portal
*/
export function getSiteBase() {
if (process.env.TALKS_PORTAL_DEV === '1') return ''
const raw = process.env.SITE_BASE?.trim() || '/'
if (raw === '/') return ''
return raw.replace(/\/+$/, '')
}
/** Valeur `base` VitePress : `/` ou `/mon-projet/` */
export function vitepressAppBase() {
if (process.env.TALKS_PORTAL_DEV === '1') return '/'
const raw = process.env.SITE_BASE?.trim()
if (!raw || raw === '/') return '/'
return raw.endsWith('/') ? raw : `${raw}/`
}
/** Chemin absolu du site : /slides/foo/ */
export function sitePath(absolutePath) {
const p = absolutePath.startsWith('/') ? absolutePath : `/${absolutePath}`
const b = getSiteBase()
return b ? `${b}${p}` : p
}