Drafts
Styx provides two approaches to manage draft content:
- Metadata
- Directories
Using metadata
By using a draft
metadata key, it possible to set a markup file to be draft data:
{---
draft = true;
---}
## Lorem ipsum
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Then, the drafts will automatically be filtered when loading the data in site.nix
when loadDir
is used.
data = {
posts = sortBy "date" "dsc" (loadDir { dir = ./path/to/posts; inherit env; });
};
This is the recommended solution as it is the easiest to set in place.
Splitting directories
In this approach, drafts are in a separate directory.
data = {
posts = let
drafts = loadDir { dir = ./path/to/drafts; inherit env; draft = true; });
posts = optionals (conf.renderDrafts == true)
(loadDir { dir = ./path/to/posts; inherit env; });
in sortBy "date" "dsc" (posts ++ drafts);
};