statix v2.0.5
Statix is a super-simple, static website generator.
Statix uses the Swig as the templating engine (if you're familiar with Django templates, Jinja or Twig, you'll feel right at home).
Installation
$ npm install -g statix
Getting Started
$ statix new project-name
$ cd project-name
$ statix build
Run those three commands, then compare the source
and deploy
directories.
Local webserver
Statix uses express (with nodemon to restart the server on changes), which means you don't have to build everytime you make a change.
$ cd project-name
$ statix server
About the statix.js config file
All the config for Statix, happens through the statix.js file. This is the only mandatory file for any Statix project. If you cd
into a directory
with a statix.js
file in it, you can run the commands statix build
and statix server
, it's that simple.
It's all pretty self explantory and there are plenty of comments. The cool thing is that you can grab a bunch of data from a database and pass it to Statix for use in generating your static site.
var settings = {
source_dir : "source", // `source_dir` is the directory where all your source files are.
output_dir: "deploy", // `output_dir` is the directory you want to compile your static site to.
/*
Literal regexes here. Statix won't include anything, unless it matches an `include_pattern` and also does
not match an `exclude_pattern`. Checks against the full path, i.e. /Users/your.name/some/dir/site/blah.html
*/
include_patterns : [
/^(.*)$/
],
exclude_patterns : [
/^(.*)(base\.html{1})$/,
/^(.*)(\/templates{1})(.*)$/
],
/*
An array of the pages to be rendered with the template engine.
`output` is where your page will eventually live, in the static version of the site. I.e. "{output_dir}/{page.output}"
`source` is where your template lives. I.e. "{source_dir}{page.source}"
`data` is an object of variables you want to pass through to the template when it gets rendered.
*/
pages : [
{
output : "index.html",
source : "templates/index.html",
data : {}
},
{
output : "example.html",
source : "templates/example.html",
data : {}
}
],
/*
`global_data` is an object that gets passed to all pages. Note, if you set `global_data.someProp` to something
and also have `page.data.someProp`, the latter will take precedence.
*/
global_data: {
},
/*
Like `global_data`, but `build_data` only gets passed to the renderer when you build, not when viewing locally through the webserver.
`build_data` properties take precedence over `global_data` properties.
*/
build_data : {
},
// Misc. things to pass to express for the local web server, currently the only value used is port.
express : {
port: "8000"
},
/*
If you need to process some things before you're ready to generate the pages (either through the web server or compilation),
you can use this `ready` method. Common use case, you need to grab a bunch of data from a database, and are using asynch i/o
Statix, does nothing until the `callback` passed to this method is called, so once you are done with everything you need to do,
simply call `callback();`
*/
ready : function (callback) {
callback();
},
/*
Statix gives you a hook to do whatever you want before the build actually happens. You can use this method to minify js/css,
compile scss stylesheets, etc. Just be sure to invoke the `done()` function when you are ready for Statix to do it's thing.
*/
preBuild : function (done) {
done();
},
/*
Just like `preBuild()` but this method gets called after Statix has generated the static site. You can use this to
cleanup some files, git commit/push, or whatever you feel like. Just be sure to invoke the `done()` function afterwards.
*/
postBuild : function (done) {
done();
}
}
module.exports = settings;
Support for other template engines is planned and fairly ease to implement if you want to fork it :)
10 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago