0
インデックスページに「リンク」フィールドを定義しようとすると、links
フィールドを作成しても、[ERROR] Missing field $links$ in context for item index.html
というエラーが発生しました。 (少なくとも私は持っていると確信しています...)Hakyllで任意のフィールドを定義できないのはなぜですか?
-- site.hs
main = hakyll $ do
match "index.html" $ do
route idRoute
compile $ do
links <- loadAll "links/*"
let indexCtx =
listField "links" linkCtx (return links) `mappend`
constField "title" "Home" `mappend`
defaultContext
getResourceBody
>>= applyAsTemplate indexCtx
>>= loadAndApplyTemplate "templates/default.html" indexCtx
>>= relativizeUrls
match "templates/*" $ compile templateBodyCompiler
linkCtx :: Context String
linkCtx =
field "link" $ \item -> return (itemBody item)
defaultContext
-- index.html
<h2>Links</h2>
$partial("templates/link-list.html")$
-- templates/link-list.html
<ul>
$for(links)$
$link$
$endfor$
</ul>
-- links/behance.markdown
---
title: Behance
---
[Behance](https://www.behance.net/laylow)
おかげでレンダリングされます。残念ながら、コードを導入しても何も変更されません。これは、私が間違ったことをしていると私に信じさせる原因になります。 [this](http://blog.gmane.org/gmane.comp.lang.haskell.hakyll/month=20130601)の問題が発生している可能性がありますか? – pdoherty926
rebuildingの出力を '-v'引数で共有できますか(例えば' stack exec-site rebuild -v') –
[こちら](https://gist.github.com/ethagnawl/e849ed70639c8b87630418efc8fbdc40)その出力コマンドと[最新コード](https://github.com/ethagnawl/peterdohertys.website)を参照してください。再度、感謝します。 – pdoherty926