Spignite projects are common Node projects. You should be familiar with JavaScript eco-system - sorry, this tool is not for faint-hearted 💪.
Create a new folder for your website. Create package.json
that looks like this (common fields are omitted):
package.json{"scripts": {"clean": "rm -rf out","dev": "node spig.js dev","build": "node spig.js"},"dependencies": {"spignite": "^2.0.8"}}
Nothing crazy, as you can see.
Spignite expects certain folder structure to be followed. We will talk more about it later; for now just keep in mind the whole site is defined in src
subfolder.
Now, let's make some pages. Create the content for index page:
src/site/index.mdHello **world**
Spignite works with several template engines. Here we are going to use the awesome nunjucks:
src/layout/base.njk<!doctype html><html><body>{{ content | safe }}</body></html>
The last thing is to run Spignite. Add the spig.js
into your projects root:
spig.jsconst { Spig } = require('spignite');​Spig.on('/**/*.md')​._('RENDER').pageLinks().render().applyTemplate();​Spig.run();
This is the main program that runs Spignite. We will describe it in more details later. Still, it is quite clear that we define certain flow of operations over input files. Something like this:
On all md
files...
in the RENDER
phase...
make page links (i.e. change .md
to .html
)...
render all .md
content...
and apply the template.
Easy, right?
That's all - execute the following in projects root and sit and enjoy the show!
npm install && npm run build
The output would be similar to this:
Check out the out
folder! The index.html
awaits:
out/index.html<!doctype html><html><body><p>Hello <strong>world</strong></p></body></html>​
Great!