Pagination does not work with version patterns
It seems to me that pagination does not work with versions in Hakyll 4.9. In the following example:
--------------------------------------------------------------------------------
{-# LANGUAGE OverloadedStrings #-}
import Data.Monoid (mappend)
import Hakyll
--------------------------------------------------------------------------------
postListCompiler pattern = do
posts <- loadAll pattern
let ctx =
listField "posts" defaultContext (return posts) `mappend`
defaultContext
makeItem ""
>>= loadAndApplyTemplate "templates/post-list.html" ctx
versionPattern :: Pattern
versionPattern = (hasVersion "teaser")
main :: IO ()
main = hakyll $ do
match "posts/*" $ version "teaser" $ do
compile pandocCompiler
create ["index.html"] $ do
route idRoute
compile $ postListCompiler versionPattern
indexPaginate <- buildPaginateWith (return . paginateEvery 1) versionPattern (\n -> fromCapture "page-*.html" (show n))
paginateRules indexPaginate $ \_ pattern -> do
route idRoute
compile $ postListCompiler pattern
match "templates/*" $ compile templateBodyCompiler
with one post in the posts directory and the following template/post-list.html
<ul>
$for(posts)$
<li>
$title$
</li>
$endfor$
</ul>
I would expect to pages to be generated: index.html, because it is specified explicitly, and page-1.html, because there is one page to be filled. However, only index.html is created.
When I remove version "teaser" from the match "posts/*" line and change versionPattern to be "posts/*" everything works as I would expect.
Hi!
I'm having the same issue with the buildTags and buildCategories functions.
Unfortunatly, all my pages have at least one version so I can't use the same workaround as @eike .