Skip to content

Instantly share code, notes, and snippets.

@nagisa
Created February 10, 2013 20:22
Show Gist options
  • Save nagisa/4750919 to your computer and use it in GitHub Desktop.
Save nagisa/4750919 to your computer and use it in GitHub Desktop.
entryListing :: Context a -> [Item a] -> Compiler String
entryListing ctx entry = do
entryItemTpl <- loadBody "templates/entry-item.html"
applyTemplateList entryItemTpl ctx entry
makePostList ctx = makeItem ""
>>= loadAndApplyTemplate "templates/entries.html" ctx
>>= loadAndApplyTemplate "templates/base.html" ctx
>>= relativizeUrls
main :: IO ()
main = hakyll $ do
create ["entries.html"] $ do
route idRoute
compile $ do
items <- loadAll "entries/*"
let itemsList = entryListing (entryCtx tags) $ recentFirst items
let entriesCtx = mconcat [ constField "title" "Entries"
, field "entrylist" $ \_ -> itemsList
, defaultContext
]
makePostList entriesCtx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment