Simple command line utility that compiles dynamic EJS view files into static HTML, based on a manifest file in the target directory.
Install SSG from npm:
npm install ssg -g
The command syntax is:
ssg {path} {environment}
The environment argument is optional and defaults to "dev". The command will look for a config file named ssg_{environment}.json
.
To compile the current folder as "dev" environment, just run:
ssg .
The above command will use ssg_dev.json
.
Contains global data, sent to all views. Accessed via <%= config.myConfigProperty %>
in your EJS views.
Contains an array of your view files and their individual settings.
The EJS source file.
The HTML file the compiled EJS should be saved to.
Optional object of key/value data that is sent to the view. Accessed via <%= myProperty %>
in your EJS views.
{
"config": {
"root_url": "http://127.0.0.1/",
"title": "Development site"
},
"views": [
{
"input": "index.ejs",
"output": "index.html",
"data": {
"headline": "Welcome to my site",
"content": "This is an example message."
}
},
{
"input": "about.ejs",
"output": "about.html"
}
]
}
You can run SSG from Node.js, using the following code.
var ssg = require('ssg');
ssg('path/to/files', {
config: { ... },
views: [
input: 'index.ejs',
output: 'index.html',
data: { ... }
]
});