`;
const examples = [
{slug:'workspace',title:'Workspace overview',icon:'layout-dashboard',description:'A complete dashboard with navigation, metrics, and service cards.'},
{slug:'profile',title:'Profile & preferences',icon:'user-round',description:'A responsive settings form with grouped fields and save feedback.'},
{slug:'sign-in',title:'Sign in',icon:'log-in',description:'A focused authentication page with a compact form.'},
{slug:'scheduling',title:'Scheduling',icon:'calendar-days',description:'Date, date-and-time, and time controls in a practical form.'},
{slug:'custom-modal',title:'Custom modal',icon:'panels-top-left',description:'Open and close a fully controlled dialog from your own buttons.'},
{slug:'project-board',title:'Project workspace',icon:'list-checks',description:'Reorder priorities and write rich-text project updates.'},
];
const extra = {
scheduling:`page SchedulingExample {\n view {
}\n}`,
'project-board':`page ProjectBoardExample {\n state tasks = [{label:"Review designs"},{label:"Build the dashboard"},{label:"Test accessibility"}]\n view {
Project workspace
}\n}`,
};
for (const e of examples) { const old = join(pagesDir,'templates',e.slug+'.wrn'); if(existsSync(old)) unlinkSync(old); }
const css = readFileSync(join(exampleRoot,'app/styles/workspace-preview.css'),'utf8');
for(const e of examples) {
const source = extra[e.slug] || readFileSync(join(exampleRoot,'examples',e.slug+'.wrn'),'utf8');
const at = source.lastIndexOf('\n }');
let rendered;
if(at>=0) rendered = source.slice(0,at)+codePanel(source)+`Page styles · copy with the example
${escapeCode(css)}
`+source.slice(at);
else rendered = source.replace(/}\s*}\s*$/,codePanel(source)+' } }');
rendered = rendered.replace(/\bview\s*\{/, 'view {\n');
write(`preview/${e.slug}.wrn`, rendered);
}
write('preview/index.wrn',page('PreviewIndex','Examples',`Ready to use
Page examples
Explore complete layouts, interact with the controls, and copy the source.
${cards(examples.map(e=>({...e,href:'/preview/'+e.slug})))}`));
const templateGroups = [
{slug:'dashboards',title:'Dashboards & admin',icon:'layout-dashboard',description:'Analytics and account operations with meaningful metrics.',heading:'Workspace performance',body:``},
{slug:'commerce',title:'Commerce',icon:'shopping-bag',description:'A product collection with a working shopping bag.',heading:'Everyday essentials',body:`
Thoughtfully made tools for your desk.
Shopping bag: {bag} items
`},
{slug:'marketing',title:'Marketing websites',icon:'sparkles',description:'A SaaS landing page with benefits, pricing, and a clear next step.',heading:'Make room for your best work.',body:`
One calm workspace for projects, notes, and the people behind them.
`},
{slug:'productivity',title:'Productivity',icon:'list-checks',description:'A planning workspace for priorities, deadlines, and notes.',heading:'Your week, in focus',body:``},
];
write('templates.wrn',page('Templates','Templates',`Start a product
Templates for your next idea
Four starting points with complete layouts and copyable source. Examples demonstrate controls; templates combine them into a product page.
${cards(templateGroups.map(e=>({...e,href:'/templates/'+e.slug})))}`));
for (const t of templateGroups) {
const source = `page ${t.slug.replace(/-/g,'')}Template {
state bag: number = 0
view {
Real sections with live previews and complete source code.
${cards(blockCards)}`));
write('blocks/index.wrn',page('BlocksIndex','UI blocks',cards(blockCards)));
// Update internal guides to point to the moved block documentation.
for(const directory of [pagesDir,join(pagesDir,'components')]) for(const file of readdirSync(directory).filter(f=>f.endsWith('.wrn'))) {
const path=join(directory,file);let text=readFileSync(path,'utf8');
for(const c of blockComponents) text=text.replaceAll('/components/'+slugOf(c.name),'/blocks/'+slugOf(c.name));
if (text !== readFileSync(path,"utf8")) writeFileSync(path,text);
}
}