Skip to content

Instantly share code, notes, and snippets.

@duk3luk3
Created January 14, 2014 00:35
Show Gist options
  • Save duk3luk3/8410855 to your computer and use it in GitHub Desktop.
Save duk3luk3/8410855 to your computer and use it in GitHub Desktop.
-- | Creates a compiler to render a post list with a category headline
categoryPostList :: Pattern
-> String
-> Context String
-> ([Item String] -> Compiler [Item String])
-> Compiler String
categoryPostList pattern catname postCtx sortFilter = do
let catCtx =
constField "category" catname `mappend`
defaultContext
posts <- sortFilter =<< loadAll pattern
catTpl <- loadBody "templates/post-by-category.html"
itemTpl <- loadBody "templates/post-item.html"
applyTemplateList itemTpl postCtx posts
>>= applyTemplate catTpl catCtx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment