我才意识到这是我自己的问题。哦,这是我找到的答案,以防其他人需要它。
我没有尝试过,但改编自http://mattwetmore.me/posts/hakyll-list-metadata.html:
listContextWith :: Context String -> String -> Context a
listContextWith ctx s = listField s ctx $ do
identifier <- getUnderlying
metadata <- getMetadata identifier
let metas = maybe [] (map trim . splitAll ",") $ M.lookup s metadata
return $ map (\x -> Item (fromFilePath x) x) metas
listContext :: String -> Context a
listContext = listContextWith defaultContext
-- and in main, in the match postsPattern part:
tagContext = listContext "tags" <> defaultContext
阅读整篇文章以尝试了解它。它应该工作。