Skip to content

AlynxZhou/hexo-renderer-nunjucks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 false because Hexo renders markdown to HTML, Nunjucks just place strings. If you set it to truex, 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:

  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

About

Yet another Nunjucks renderer for Hexo.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published