1.0.0 • Published 6 years ago

hexo-renderer-njucks v1.0.0

Weekly downloads
3
License
Apache-2.0
Repository
github
Last release
6 years ago

hexo-renderer-njucks

Yet another Nunjucks renderer for Hexo. Async, alive and can be actively updated.

WHY?

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.

READ HERE BEFORE USING IT OR CREATING YOUR OWN THEME WITH NUNJUCKS:

By default it set autoescape to true because Hexo renders markdown to HTML, Nunjucks just place strings.

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:

  1. 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 with for 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, use toArray() method like page.posts.toArray(), which is mentioned by @tommy351 (author of Hexo) here.

  2. hexo-renderer-Nunjucks and hexo-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.

LICENSE:

Apache-2.0

1.0.0

6 years ago