ontoref-outreach/scripts/decks/lib/paths.mjs
2026-07-17 01:00:32 +01:00

26 lines
1.5 KiB
JavaScript

// Shared path + dependency resolution for the deck projection.
//
// postcss and playwright-chromium are devDependencies of outreach/presentation/ (they
// are Slidev's neighbours, and Slidev is what we drive). Resolve them from there
// explicitly: pnpm is strict, so nothing is hoisted to a top-level node_modules.
import { createRequire } from 'node:module'
import { fileURLToPath } from 'node:url'
import { dirname, resolve } from 'node:path'
const HERE = dirname(fileURLToPath(import.meta.url)) // outreach/scripts/decks/lib
export const OUTREACH = resolve(HERE, '../../..') // outreach/
export const PRESENTATION = resolve(OUTREACH, 'presentation')
export const SITE = resolve(OUTREACH, 'site/site') // content/ + public/ live here
export const distDir = (id) => resolve(PRESENTATION, 'builds', id) // one build per deck
const require_ = createRequire(resolve(PRESENTATION, 'package.json'))
export const postcss = require_('postcss')
export const { chromium } = require_('playwright-chromium')
export const publicBase = (id) => `/images/decks/${id}`
export const publicDir = (id) => resolve(SITE, `public/images/decks/${id}`)
// Category segment is localized (see decks.ncl `category`): ES decks live under
// content/resources/es/presentaciones/, EN under en/decks/. The loader resolves the body by
// {lang}/{category}/{id}.md, so the DIRECTORY must match the URL category, not only the frontmatter.
export const contentFile = (lang, id, category = 'decks') => resolve(SITE, `content/resources/${lang}/${category}/${id}.md`)