Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | import { StaticRuntime } from '@coherentjs/runtime/static'; // Create components const Layout = ({ title, children }) => ({ html: { head: { title: { text: title }, meta: [ { charset: 'utf-8' }, { name: 'viewport', content: 'width=device-width, initial-scale=1' } ] }, body: { children: [ { header: { h1: { text: 'My Static Site' } } }, { main: { children } }, { footer: { p: { text: '© 2025 My Site' } } } ] } } }); const HomePage = () => Layout({ title: 'Home', children: [ { h2: { text: 'Welcome!' } }, { p: { text: 'This is a static site built with Coherent.js' } } ] }); const AboutPage = () => Layout({ title: 'About', children: [ { h2: { text: 'About Us' } }, { p: { text: 'We build awesome static sites!' } } ] }); // Build the site const site = StaticRuntime.createApp({ outputDir: 'dist', baseUrl: 'https://mysite.com' }); site.component('Layout', Layout); site.component('HomePage', HomePage); site.component('AboutPage', AboutPage); site.page('/', 'HomePage'); site.page('/about', 'AboutPage'); const result = await site.build(); console.log(`Built ${result.stats.pagesGenerated} pages in ${result.stats.buildTime}ms`); |