1.1.0 • Published 7 years ago
desq-static v1.1.0
desq-static
Build static sites using desq.
Status
This is an early version of desq-static
and configuration or usage may change in the future.
Installation
npm install desq-static
Configuration
Create a file page.js
which will contain the configuration & entry point for desq-static
.
require('desq-static')(module, {
// Required:
basedir: __dirname + '/page',
prepare: client => {
// Configure the desq client instance:
// See https://desq-stack.github.io/desq/
client.add(new Pug());
client.add(new Less());
}
// Optional:
output: __dirname + '/dist',
// If output is not specified here, it must be explicitly set from command line or api!
});
The configuration above will use the following folder structure for the page:
/page.js - Your configuration.
/page
/sources - Sources to render using components.
/assets - Static files.
Command line usage
node page.js # will simply build the page.
--output, -o ...path...
Specifies the output path for building the page.
node page.js --output path/to/my/output/directory
node page.js -o path/to/my/output/directory
--serve, -s
A simple web server will be started serving the page.
The default port is 8080
.
node page.js --serve
node page.js -s
--live, -l
Use with --serve
. Enables live reloading on the browser using socket.io
.
node page.js --serve --live
node page.js -sl
--port, -p
Use with --serve
. Specifies the port for running the web server.
node page.js --serve --port 3000
node page.js -sp 3000
Usage from code
// Simply require the configuration file:
const renderPage = require('./page.js');
renderPage({
output: 'path/to/output' // Optional.
}).then(() => {
console.log('Done rendering.');
}, err => {
console.error(err);
});
renderPage
returns a promise and all arguments passed to it are optional.
Contributing
See the contributing section in desq/readme