suo sews together your JSON data with handlebars templates to generate a static website.
Usage: node suo.js
Alternate usage: node suo.js someotherdatafile.json
This is still very alpha.
FAQ:
- Q: isn't there already a million static website generators that do this same thing? A: First of all "aren't there", and yes, I just wanted to do something similar to jekyll-perf and I also wanted to play around with node
How it works:
Files & folders:
files
: this folder includes all static and binary files of the site: images, css/scss, js, etcf
: any font binaries go herei
: any images go herej
: any javascript files go here, currently, main.js is the only file that will be compressed by uglifys
: any stylesheets go here, css or scss, compass and its dependent binaries should be installed separatelynode_modules
: this folder is generated by node when the required modules are imported by npmtemplates
: this is where all the handlebars templates for content arewww
: the destination folder where all files will be placed.gitignore
: standard git ignore filedata.json
: this is the JSON source of all data for the siteLICENSE
: MIT license filepackage.json
: node js package fileREADME.md
: standard readmesuo.js
: the code to be executed
npm list
:
suo@0.0.1
├── adm-zip@0.4.4
├── async@0.2.10
├─┬ fs.extra@1.2.1
│ ├─┬ fs-extra@0.6.4
│ │ ├── jsonfile@1.0.1
│ │ ├── ncp@0.4.2
│ │ └── rimraf@2.2.6
│ ├── mkdirp@0.3.5
│ └─┬ walk@2.2.1
│ └─┬ forEachAsync@2.2.1
│ └── sequence@2.2.1
├─┬ handlebars@2.0.0-alpha.2
│ ├─┬ optimist@0.3.7
│ │ └── wordwrap@0.0.2
│ └─┬ uglify-js@2.3.6
│ └─┬ source-map@0.1.33
│ └── amdefine@0.1.0
├── html-minifier@0.5.6
├── moment@2.6.0
├── node-json-minify@0.1.3-a
└─┬ uglify-js@2.4.13
├─┬ optimist@0.3.7
│ └── wordwrap@0.0.2
├─┬ source-map@0.1.33
│ └── amdefine@0.1.0
└── uglify-to-browserify@1.0.2
Order of operation:
- there are a few config settings at the top of suo.js, if the paths in the
files
directory have changed then they need to be updated - if files exist in the destination folder (
www
), they are archived - if files exist in the destination folder, they are deleted
- if the destination folder doesn't exist it is created
- assets are copied from the source folder (
files
) - css/scss and js files are versioned and renamed based on their date modified
- the json data is parsed
- helper functions for handlebars are registered:
1.
moment
: date/time helper that uses moment js 2.startsWith
: boolean string function 3.equals
: boolean string function 4.coalesce
: inspired by SQL COALESCE, returns first non-null value 5.static
: references the static files processed and returns the correct path/name 6.gravatar
: returns gravatar hash for a given string - handlebars templates from json data are processed
- pages from json data are processed
- list pages are processed: post archive, categories, rss/atom, home, manifest, sitemap
- the sitemap.xml file is gzipped
- time elapsed is displayed
TODOs:
- so many callbacks
- not generic enough
- so many refactorings
- include optional image compression?
- enable a dev mode for debugging css & js
Example site using suo: http://dieseltravis.github.io/