I'm trying to construct a site with 7 pages. Each page is defined using a .markdown input. On each page I want a header with links to all the other pages.
Now, this seems to be impossible since Hakyll tells me that I have a recursive dependency.
[ERROR] Hakyll.Core.Runtime.chase: Dependency cycle detected: posts/page1.markdown depends on posts/page1.markdown
I have identified the recursive dependency to this snippet.
match "posts/*" $ do
route $ setExtension "html"
compile $ do
posts <- loadAll "posts/*"
let indexCtx =
listField "posts" postCtx (return posts) `mappend`
constField "title" "Home" `mappend`
defaultContext
pandocCompiler >>= loadAndApplyTemplate "templates/post.html" indexCtx
>>= loadAndApplyTemplate "templates/default.html" indexCtx
>>= relativizeUrls
I guess the problem is that I'm not allowed to match on the same template that a do a load on.
So how can I construct a context with a listField for all posts to be used when generating posts.
I guess an alternative would be to generate the links first, store them somehow and then include them in the posts. But how would I do that?