← back to Wallpaper Paint Antics
series2/build.mjs
16 lines
import fs from 'node:fs';
import path from 'node:path';
const root=import.meta.dirname;
const episodes=JSON.parse(fs.readFileSync(path.join(root,'episodes.json')));
const products=JSON.parse(fs.readFileSync(path.join(root,'products.json')));
const audio=JSON.parse(fs.readFileSync(path.join(root,'audio.json')));
const animation=fs.readFileSync(path.join(root,'animation.js'),'utf8');
for(const [i,ep] of episodes.entries()){
const make=(prefix)=>`<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=1080,height=1920"><title>Wallo presents — ${ep.shortTitle}</title><style>@font-face{font-family:Georgia;src:url('${prefix}assets/georgia.ttf')}@font-face{font-family:Verdana;src:url('${prefix}assets/verdana.ttf')}html,body{margin:0;width:1080px;height:1920px;overflow:hidden}#root{position:relative;width:1080px;height:1920px;overflow:hidden}.clip{position:absolute;inset:0;width:1080px;height:1920px}canvas{width:1080px;height:1920px}.preload{position:absolute;opacity:0;pointer-events:none}</style><script src="${prefix}assets/gsap.min.js"></script></head><body><div id="root" data-composition-id="main" data-start="0" data-duration="20" data-width="1080" data-height="1920" data-fps="30"><section id="material-scene" class="clip" data-start="0" data-duration="20" data-track-index="0"><canvas id="stage" width="1080" height="1920" aria-label="Wallo presenting ${ep.shortTitle.replaceAll('"','')}"></canvas><span class="preload" style="font-family:Georgia">Wallo</span><span class="preload" style="font-family:Verdana">Designer Wallcoverings</span></section><audio id="narrated-mix" src="${prefix}assets/mix-${i}.wav" data-start="0" data-duration="20" data-track-index="1"></audio></div><script>window.EPISODE=${JSON.stringify({...ep,index:i,audio:audio[i]})};window.PRODUCTS=${JSON.stringify(products.map(p=>({...p,local:prefix+p.file})))};${animation}</script></body></html>`;
fs.writeFileSync(path.join(root,'episodes',ep.slug+'.html'),make('../'));
fs.mkdirSync(path.join(root,'verification','check-'+ep.slug),{recursive:true});
fs.writeFileSync(path.join(root,'verification','check-'+ep.slug,'index.html'),make('../../'));
if(i===0)fs.writeFileSync(path.join(root,'index.html'),make(''));
}
console.log('Built five 20-second Wallo presentation compositions.');