Spg - Static Page Generator
Simple generator static pages. To generate use swig templates and markdown files to create content. Spg allows you to define multiple pages and a series from specified directory. Only what you need is other web server (like apache or nginx), define templates in swig and configuration ini file.
Install
npm install -g spg
Tutorial
You must create dirs, config file, md files with content and templates.
mkdir my-test-page
cd my-test-page
mkdir articles
mkdir public
mkdir view
touch config.ini
Edit config.ini and define pages:
[_global]config.destonationPath = public/ ; path wher new file was create config.fileName = index.html ; file name [index : _global] ; inherits the settings from the section _global config.templateFile = view/index.html ; template file for site "index" config.fileName = index.html ; file name ; define for series pages articles.sourcePath = articles/ ; path where searh md files articles.order = path ; order files by articles.destonationPath = public/articles/ ; destonation generated files articles.ext = html ; change md extension for html articles.templateFile = view/article.html ; template file [history : index] ; inherits the settings from the section index config.templateFile = view/history.html ; change template name config.fileName = history.html ; change destonation file name [about : _global]config.templateFile = view/about.htmlconfig.fileName = about.html
Create templates in view
dir How to create templates files
If you want use article's list in template, you must write something like this:
{% for art in articles %} {{ art.introText|raw }} Czytaj więcej Komentuj {% endfor %}
Article atributes:
art = fullText: /* html file generated from md */ introText: /* html file generated from md to tag <!-- more --> */ firstLine: /* first line from md */ sourcePath: /* path to md file */ sourceRelPath: /* relative path to file */ destPath: /* destonation path to html file */ destRelPath: /* relative path to html file (can be use to create links) */ size: /* size md file */ atime: /* data from fs.statSync */ mtime: /* data from fs.statSync */ ctime: /* data from fs.statSync */
In view/article.html
template use variable data
% block content % datafullText|raw % endblock %
Ok you have config and templates. Create yours .md pages in articles/
dir and run commend:
spg --config=config.ini
In "public" should appear html files.
Configure your webserwer and is done.
Help
Create a issue if something is not clear.