I am moving my blog to hakyll.
In my webdesign at the index page there are horizontal rows with 3 post previews in each. Css/js is made in such a way, that I'd better populate this row not with all posts I have, allowing them to flow automatically, but I'd better cut posts list to chunks of 3 posts in each and generate separate row with 3 posts for each chunk.
So instead of
- row
- col-sm-4 - col-sm-4 - col-sm-4
- col-sm-4 ...
I want to have
- row
- col-sm-4 - col-sm-4 - col-sm-4
- row
- col-sm-4 - col-sm-4 - col-sm-4
...
In my site.hs
I have quite typical
match "blog.html" $ do
route cleanRoute
compile $ do
posts <- recentFirst =<< loadAll "posts/**"
let indexCtx =
listField "posts" postCtxWithCat (return posts) `mappend`
favCtx
getResourceBody
>>= applyAsTemplate indexCtx
>>= loadAndApplyTemplate "templates/default.html" indexCtx
>>= relativizeUrls
>>= cleanIndexUrls
And now I want to cut posts to chunks of 3.
posts <- recentFirst =<< loadAll "posts/**"
let postsBy3 = chunksOf 3 posts -- from split package
But how to feed this postsBy3 :: [[Item String]]
further to template and how to use it... is a big question.
Just doing
listField "postsBy3" postCtxWithCat (return postsBy3) `mappend`...
is clearly a type mismatch.
Stuck.