import {readFileSync,writeFileSync,readdirSync} from 'node:fs'; const web=new URL('../web/',import.meta.url),posts=JSON.parse(readFileSync(new URL('prophecy-data.json',web),'utf8')); const extended=new URL('../content/prophecy/',import.meta.url),graphicData=JSON.parse(readFileSync(new URL('prophecy-graphics.json',web),'utf8')); for(const post of posts){const essay=readFileSync(new URL(post.id+'.md',extended),'utf8');const sections=essay.split(/^# /m).slice(1).map(block=>{const [heading,...lines]=block.trim().split('\n');return {heading,paragraphs:lines.join('\n').trim().split(/\n\s*\n/).filter(Boolean)}});post.sections.push(...sections);post.words=post.sections.flatMap(x=>x.paragraphs).join(' ').split(/\s+/).length;if(post.words<3000)throw Error(post.id+' has only '+post.words+' words');post.minutes=Math.ceil(post.words/200)} const escape=s=>s.replace(/[&<>"']/g,c=>({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c])); const links=[['index.html','Home','menu-6'],['manual.html','Manual/wiki','menu-5'],['prophecy.html','The Prophecy','item-28'],['exchange.html','Xchange','menu-0'],['forums.html','Forums','menu-4'],['discord.html','Discord','menu-3'],['tickets.html','Support tickets','menu-9']]; function top(file){return ''} for(const file of readdirSync(web).filter(f=>f.endsWith('.html'))){let s=readFileSync(new URL(file,web),'utf8');s=s.replace(/