Created
May 30, 2011 09:16
-
-
Save paul-r-ml/998640 to your computer and use it in GitHub Desktop.
Hakyll, list posts grouped by year
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
---- group posts by years | |
groupByYear :: [Page a] -> [(String, [Page a])] | |
groupByYear = map (\pg -> ( year (head pg), pg) ) . | |
groupBy (\ a b -> year a == year b) | |
where year :: Page a -> String | |
year = take 4 . takeBaseName . getField "path" | |
addYearList :: String | |
-> [Page String] | |
-> Compiler () (Page String) | |
addYearList y posts = constA (mempty, posts) | |
>>> addPostList | |
>>> arr (setField "postsYear" y) | |
>>> applyTemplateCompiler "templates/postsYear.html" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment