-
Notifications
You must be signed in to change notification settings - Fork 419
Description
I am learning hakyll and I have trouble reading from a context that depends on files that are also copied. Not coping the files fixes the issue (but then the files won't be available in _site). This might be related to #719, however I have tried the suggestions mentioned there and I get compiler errors at build time. I was unable to change Context String to Context CopyFile.
If I build the site twice it would work, because the files would already have been copied during the first run. For this reason (and seeing that #719 is still open) I suspect that it is a bug in the dependency tracking.
I made the following changes to the code initialized with hakyll.
site.hs
main :: IO ()
main = hakyll $ do
-- copy the icons to _site
match "static/assets/88x31/*" $ do
route idRoute
compile copyFileCompiler
match "index.html" $ do
route idRoute
compile $ do
posts <- recentFirst =<< loadAll "posts/*"
let indexCtx =
-- Here I try to create a context that is a list of all the icons
listField "buttons" defaultContext (loadAll "static/assets/88x31/*") `mappend`
listField "posts" postCtx (return posts) `mappend`
defaultContext
getResourceBody
>>= applyAsTemplate indexCtx
>>= loadAndApplyTemplate "templates/default.html" indexCtx
>>= relativizeUrls
match "templates/*" $ compile templateBodyCompilertemplate/default.html
I want to loop over a list of icons at the bottom of all pages.
<main role="main">
<h1>$title$</h1>
$body$
<div class="button-container">
$for(buttons)$
<img class="button-item" src="$path$">
$endfor$
</div>
</main>
Thank you for your time :)