How to create a “project” in nanok?

I would like to display messages in different folders depending on the status code in the metadata.

For example, if I have the status: draft attribute, I would like these items to appear in a folder named /draft/ , and status: live in /blog/ . Then I could password protect the draft folder so that I can view it. If there is no status at all, a draft will be executed by default.

Is it possible?

+4
source share
1 answer

In your rules file, use the following:

 route '*' do if item.binary? item.identifier.chop + '.' + item[:extension] elsif item[:status] '/' + item[:status] + item.identifier.chop + '.' + item[:extension] else item.identifier + 'index.html' end end 

This will create a directory for each of your statuses. For example: source file starting with

 --- title: file1 status: testing --- 

will be created in the / testing / folder.

To delete the remaining files after compilation, you can use "nanoc prune" (new in nanoc 3.3.x).

+4
source

Source: https://habr.com/ru/post/1390206/


All Articles