Marcel van der Boom
2016-07-18 15:30:25 UTC
Hi everyone,
I'm (ab-)using the conversion of my blog to hakyll to learn Haskell. I've
got the basic plumbing done I think, but I've been battling to get tag
index pages to work.
I'm generating a "grouped post list"-page which works fine for archives,
but using the same principle for tag index pages gives me empty pages.
I've included some relevant code snippets below. I think it may have
something to do with the different versions perhaps? (i use orgmode as
sourceformat and publish source and html)
Need a little push in the right direction.
Thanks,
marcel
--- snip ---
postsPattern :: Pattern
postsPattern =
"sites/main/_posts/2*.org"
-- Creating the archive page, grouped by year
-- This works fine
archiveR :: Rules ()
archiveR =
create ["archive/index.html"] $ do
let title = "Archives"
route idRoute
compile $ groupedPostList title postsPattern
-- This does the grouping
groupedPostList :: String -> Pattern -> Compiler (Item String)
groupedPostList title pattern = do
posts <- fmap groupByYear $
recentFirst
=<< loadAllSnapshots (pattern .&&. hasVersion "html") "html"
let ctx =
constField "title" title <>
listField "years"
(
field "year" (return . fst . itemBody) <>
listFieldWith "posts" postCtx (return . snd . itemBody)
)
(sequence $ fmap (\(y, is) -> makeItem (show y, is)) posts) <>
baseContext
makeItem ""
-- This generates the html pages, but they are all empty
tagsR :: Rules ()
tagsR = do
tags <- buildTags postsPattern (fromCapture "tag/*/index.html")
-- Use the tagsRules function to generate the pages
tagsRules tags $ \tag pattern -> do
let title = "Posts tagged \"" ++ tag ++ "\""
route idRoute
compile $ groupedPostList title pattern
--- snip ---
I'm (ab-)using the conversion of my blog to hakyll to learn Haskell. I've
got the basic plumbing done I think, but I've been battling to get tag
index pages to work.
I'm generating a "grouped post list"-page which works fine for archives,
but using the same principle for tag index pages gives me empty pages.
I've included some relevant code snippets below. I think it may have
something to do with the different versions perhaps? (i use orgmode as
sourceformat and publish source and html)
Need a little push in the right direction.
Thanks,
marcel
--- snip ---
postsPattern :: Pattern
postsPattern =
"sites/main/_posts/2*.org"
-- Creating the archive page, grouped by year
-- This works fine
archiveR :: Rules ()
archiveR =
create ["archive/index.html"] $ do
let title = "Archives"
route idRoute
compile $ groupedPostList title postsPattern
-- This does the grouping
groupedPostList :: String -> Pattern -> Compiler (Item String)
groupedPostList title pattern = do
posts <- fmap groupByYear $
recentFirst
=<< loadAllSnapshots (pattern .&&. hasVersion "html") "html"
let ctx =
constField "title" title <>
listField "years"
(
field "year" (return . fst . itemBody) <>
listFieldWith "posts" postCtx (return . snd . itemBody)
)
(sequence $ fmap (\(y, is) -> makeItem (show y, is)) posts) <>
baseContext
makeItem ""
= loadAndApplyTemplate "_layouts/grouped.html" ctx
= loadAndApplyTemplate "_layouts/default.html" ctx
= relativizeUrls
-- Do the same for /tag/whatever/index.html pages= loadAndApplyTemplate "_layouts/default.html" ctx
= relativizeUrls
-- This generates the html pages, but they are all empty
tagsR :: Rules ()
tagsR = do
tags <- buildTags postsPattern (fromCapture "tag/*/index.html")
-- Use the tagsRules function to generate the pages
tagsRules tags $ \tag pattern -> do
let title = "Posts tagged \"" ++ tag ++ "\""
route idRoute
compile $ groupedPostList title pattern
--- snip ---
--
You received this message because you are subscribed to the Google Groups "hakyll" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hakyll+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "hakyll" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hakyll+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.