/** Rebuild standalone demos and schematic covers; no browser or external assets. */ import {mkdir,writeFile} from 'node:fs/promises'; import path from 'node:path'; import sharp from 'sharp'; import {recipes,recipeHtml} from '../src/content/layouts/documents'; async function main(){ const target=path.resolve(import.meta.dirname,'../public/layout-recipes'); await mkdir(target,{recursive:true}); const esc=(s:string)=>s.replaceAll('&','&').replaceAll('<','<').replaceAll('>','>'); const outer=(inside:string)=>`${inside}`; for(const [i,r] of recipes.entries()){ const graphic=outer(`${r.shapes}FORM STUDIES / ${String(i+1).padStart(2,'0')}${esc(r.name)}结构示意 · 非代码截图HTML / REACT / NEXT.JS`); await writeFile(path.join(target,r.slug+'.html'),recipeHtml(r)+'\n'); await sharp(Buffer.from(graphic)).png().toFile(path.join(target,r.slug+'.png')); } const cards=recipes.map((r,i)=>{const col=i%3,row=Math.floor(i/3);return `${r.shapes}${String(i+1).padStart(2,'0')}${esc(r.name.slice(0,4))}${esc(r.name.slice(4))}`}).join(''); await sharp(Buffer.from(outer(`FORM STUDIES / DESIGN ROUTER高级感排版${cards}12 套构图 / 选择 → 实现 → 验收 · 结构索引`))).png().toFile(path.join(target,'router.png')); console.log(`Generated ${recipes.length} standalone HTML demos and ${recipes.length+1} schematic PNGs.`); } main().catch(error=>{console.error(error);process.exitCode=1});