Giedrius Kudelis
2015-12-06 16:53:16 UTC
Hello!
I'm trying to get all my post pages to show a list of all posts on the blog
and link to them. Kind of like an archive on every page in the sidebar. I
got the list of posts to be shown using versions. The post titles and dates
are correct, however the link URLs are all pointing to the current page.
Here's what I have in my site.hs:
main :: IO ()
main = hakyll $ do
(stuff here...)
match "posts/*" $ do
route $ setExtension "html"
compile $ pandocCompiler
match "posts/*" $ version "plain" $ do
compile $ getResourceBody
(more stuff here...)
--------------------------------------------------------------------------------
plainPostCtx :: Context String
plainPostCtx =
dateField "date" "%B %e, %Y" <>
defaultContext
postListCtx :: Context String
postListCtx =
listField "allPosts" plainPostCtx (recentFirst =<< (loadAll $ "posts/*"
.&&. hasVersion "plain"))
postCtx :: Context String
postCtx =
postListCtx <>
plainPostCtx
The base template (templates/base.html) uses a partial
(templates/post-list.html) which uses the allPosts list. Here's what I have
in post-list.html:
<ul class="post-list">
$for(allPosts)$
<li>
<a href="$url$">$title$</a> - $date$
</li>
$endfor$
</ul>
If you need to have a look at the whole
repo: https://github.com/gkudelis/gkudelis.github.io/tree/source
I've had a look at the list of pages using hakyll and this does what I
want: http://dannysu.com/2015/10/31/regex-nfa/ (it has a list of most
recent posts in the footer). I had a look at the code, but could not figure
out what I'm doing wrong. Please help, it feels like I'm missing some small
detail, but I'm new to haskell and hakyll and I'm feeling pretty clumsy :).
Best Regards,
Giedrius Kudelis
I'm trying to get all my post pages to show a list of all posts on the blog
and link to them. Kind of like an archive on every page in the sidebar. I
got the list of posts to be shown using versions. The post titles and dates
are correct, however the link URLs are all pointing to the current page.
Here's what I have in my site.hs:
main :: IO ()
main = hakyll $ do
(stuff here...)
match "posts/*" $ do
route $ setExtension "html"
compile $ pandocCompiler
= loadAndApplyTemplate "templates/post.html" postCtx
= loadAndApplyTemplate "templates/base.html" postCtx
= relativizeUrls
-- get unchanged versions too for rendering the post list= loadAndApplyTemplate "templates/base.html" postCtx
= relativizeUrls
match "posts/*" $ version "plain" $ do
compile $ getResourceBody
(more stuff here...)
--------------------------------------------------------------------------------
plainPostCtx :: Context String
plainPostCtx =
dateField "date" "%B %e, %Y" <>
defaultContext
postListCtx :: Context String
postListCtx =
listField "allPosts" plainPostCtx (recentFirst =<< (loadAll $ "posts/*"
.&&. hasVersion "plain"))
postCtx :: Context String
postCtx =
postListCtx <>
plainPostCtx
The base template (templates/base.html) uses a partial
(templates/post-list.html) which uses the allPosts list. Here's what I have
in post-list.html:
<ul class="post-list">
$for(allPosts)$
<li>
<a href="$url$">$title$</a> - $date$
</li>
$endfor$
</ul>
If you need to have a look at the whole
repo: https://github.com/gkudelis/gkudelis.github.io/tree/source
I've had a look at the list of pages using hakyll and this does what I
want: http://dannysu.com/2015/10/31/regex-nfa/ (it has a list of most
recent posts in the footer). I had a look at the code, but could not figure
out what I'm doing wrong. Please help, it feels like I'm missing some small
detail, but I'm new to haskell and hakyll and I'm feeling pretty clumsy :).
Best Regards,
Giedrius Kudelis
--
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.