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 .html
root
locationroot/index.html
page_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.
---
extension: php
---
Having a php extension allows to include raw php code through oneliner comments. For example:
<!-- gen.py: include '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>
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.