Yes, this is yet another static site generator.
I use raw python template and markdown syntax with little tweaking.
It has been inspired by this post
on Hacker News.
Look at gen.py for details.
I try to keep it simple stupid.
Principles are:
.md files are converted to .htmlroot locationpage_title metadata_templates/default.html)Only .md files with activated publication are generated in the target directory hierarchy.
---
published: yes
---
With the following metadata gen.py will use _template\my_template.html
instead of _template\default.html
---
template: my_template
---
As an alternative to the default .html file generation, it is possible to
generate a .php file. It can be forced through:
---
extension: php
---
It is automatic when a PHP addon is used through oneliner comments. For example:
<!-- php: citation.php -->
will put
<?php include 'citation.php' ?>
in the php output file.
This is how the dynamic citation of the main index page is done and the
citation.php file contains something like:
<div id="citation">
<?php
$json_str = file_get_contents('citations.json');
$arr = json_decode($json_str);
$entry_id = random_int(0, count($arr)-1);
echo $arr[$entry_id];
?>
</div>
It is possible to load one addon per markdown file. The following meta-data
loads module_name.py from the markdown file directory.
---
addon: module_name
---
Once loaded, it is possible to call functions from this module to generate additional outputs. Currently, it only support generation of markdown outputs through oneliner comments such as:
<!-- addon: function_name() -->
With markdown_addon it calls function_name within the markdown data before
the HTML production.
For converting markdown .md files to .html I use
markdown it py with core plugins
(mdit-py-plugins).
Install it using the pip install markdown-it-py[plugins] command.