-
Notifications
You must be signed in to change notification settings - Fork 419
Description
Hello, thanks a lot for your work on this framework. The following is more of a question, not really an issue.
From my understanding of Hakyll, I believe one file (matched by a match rule) can only generate one Identifier (along some compilation rules that are triggered when necessary). However I was considering the following:
- have a single JSON file that describes a collection of items (like a list of photos for an album 1);
- generate several pages which correspond to a paginated representation of the items.
Generating a single Compiler (Item [MyObject]) while matching a valid JSON file is easy to do. However pagination only works with a given list of Identifiers (obtained from a Pattern):
buildPaginateWith
:: MonadMetadata m
=> ([Identifier] -> m [[Identifier]]) -- ^ Group items into pages
-> Pattern -- ^ Select items to paginate
-> (PageNumber -> Identifier) -- ^ Identifiers for the pages
-> m PaginateIt is always possible to perform some IO with the preprocess :: IO a -> Rules a function and iterate on the create rule from there, but this completely escapes the dependency mechanism; also, it means doing it for several JSON files cannot naturally be done with a e.g. match ["dir/*.json"] rule.
So I was wondering if there is any construction in Hakyll that would allow this more "idiomatically"?
Footnotes
-
I understand that Hakyll seems very "file-based" and that a natural alternative to what is presented here would be to have instead one file per list item and have Hakyll manage that properly, like what is done in the repo of jaspervdj. My questioning arises mostly because I find using a single JSON file more convenient and less verbose from the perspective of git. ↩