Skip to content

Instantly share code, notes, and snippets.

@paul-r-ml
Created May 30, 2011 09:16
Show Gist options
  • Save paul-r-ml/998640 to your computer and use it in GitHub Desktop.
Save paul-r-ml/998640 to your computer and use it in GitHub Desktop.
Hakyll, list posts grouped by year
---- 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