Yet another Nunjucks renderer for Hexo. Async, alive and can be actively updated.
Both hexo-renderer-nunjucks
and hexo-renderer-njk
and hexo-renderer-njks
are using Nunjucks version 2, and seems their author won't update them to Nunjucks 3. They take the best name in npm, but leave code unmaintained! So I write my own hexo renderer to render my theme ARIA.
By default it set autoescape
to false
because Hexo renders markdown to HTML,
Nunjucks just place strings. If you set it to true
x, you will see the <
, >
of
HTML tags on your page.
If you want to change Nunjucks config (for doc looks here), just write them in Hexo's site config _config.yml
like this:
nunjucks:
watch: true
# and other config...
If you write a Hexo theme with Nunjucks with me, I have some useful tips for you:
-
Some of Hexo's varibles are not the same type as they looks like, for example, in index template, you may think
page.posts
is an Array, but it's an Object (read here), which you cannot iterate it withfor in
, I don't know why Hexo designs it so strange (more strange, some data structure of Hexo is "Array of ???", WHAT IS???
?). OK, if you need an Array, usetoArray()
method likepage.posts.toArray()
, which is mentioned by @tommy351 (author of Hexo) here. -
hexo-renderer-Nunjucks
andhexo-renderer-njk
are using Nunjucks version 2, and some Nunjucks' keywords like===
and!==
are not supported in version 2, that's why I make this plugin.
Apache-2.0