Using templates to export markdown tiddlers to nikola compatible format

The tiddlywiki Node.js editon has a --render command which can render a tiddler with a template. And it is not difficult to export the markdown tiddlers in a format which is compatible with static site generators.

For example, this template can export tiddlers to nikola compatible format.

\rules except dash horizrule
---
title: {{!!title}}
date: {{{ [{!!modified}format:date[YYYY-0MM-0DD 0hh:0mm:0ssTZD]] }}}
tags: {{{ [enlist{!!tags}join[,]] }}}
---
`
`
<$view field="text" format="text" />

To export markdown tiddlers with the template, save the above template to $:/templates/nikola-markdown, and use this command to export all markdown tiddlers:

# The slugify operator is suggeseted to be used here
tiddlywiki mywiki --render "[type[text/markdown]] :or[type[text/x-markdown]]" "[slugify[]addprefix[nikola/]addsuffix[.md]]" "text/plain" "`$:/templates/nikola-markdown"

You can also add it to tiddlywiki.info, so that it can be run with the --build command:

"build": {
      "nikola": [
	"--render",
	"[type[text/markdown]] :or[type[text/x-markdown]]",
	"[slugify[]addprefix[nikola/]addsuffix[.md]]",
	"text/plain",
	"$:/templates/nikola-markdown"
      ]
    }
5 Likes