You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
840 B
JavaScript
36 lines
840 B
JavaScript
5 years ago
|
"use strict";
|
||
|
|
||
|
const { bluebird, fs, expand, refresh } = require( "./export.utils" );
|
||
|
|
||
|
( async () => {
|
||
|
|
||
|
// Copy static content
|
||
|
await fs.copy( expand( "website/assets" ), expand( "public" ) );
|
||
|
|
||
|
// Generate pages
|
||
|
await bluebird.each( fs.glob( "pages/**/*.js", __dirname ), async input => {
|
||
|
|
||
|
const output = input
|
||
|
.replace( expand( "website/pages" ), expand( "public" ) )
|
||
|
.slice( 0, -3 ) + ".html";
|
||
|
|
||
|
await refresh( input, output, async () => {
|
||
|
|
||
|
let page = require( input );
|
||
|
|
||
|
if ( typeof page === "function" ) page = await bluebird.method( page )();
|
||
|
|
||
|
await fs.ensureDir( fs.dirname( output ) );
|
||
|
await fs.writeFile( output, page.trim() );
|
||
|
|
||
|
} );
|
||
|
|
||
|
} );
|
||
|
|
||
|
} )().catch( err => {
|
||
|
|
||
|
console.trace( err );
|
||
|
process.exit( 1 );
|
||
|
|
||
|
} );
|