misconstruedⓂ️monologues https://blog.bemoe.online
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
2.2KB

  1. --------------------------------------------------------------------------------
  2. {-# LANGUAGE OverloadedStrings #-}
  3. import Data.Monoid (mappend)
  4. import Hakyll
  5. --------------------------------------------------------------------------------
  6. main :: IO ()
  7. main = hakyll $ do
  8. match "images/*" $ do
  9. route idRoute
  10. compile copyFileCompiler
  11. match "css/*" $ do
  12. route idRoute
  13. compile compressCssCompiler
  14. match (fromList ["about.md", "contact.markdown"]) $ do
  15. route $ setExtension "html"
  16. compile $ pandocCompiler
  17. >>= loadAndApplyTemplate "templates/default.html" defaultContext
  18. >>= relativizeUrls
  19. match "posts/*" $ do
  20. route $ setExtension "html"
  21. compile $ pandocCompiler
  22. >>= loadAndApplyTemplate "templates/post.html" postCtx
  23. >>= loadAndApplyTemplate "templates/default.html" postCtx
  24. >>= relativizeUrls
  25. create ["archive.html"] $ do
  26. route idRoute
  27. compile $ do
  28. posts <- recentFirst =<< loadAll "posts/*"
  29. let archiveCtx =
  30. listField "posts" postCtx (return posts) `mappend`
  31. constField "title" "archives" `mappend`
  32. defaultContext
  33. makeItem ""
  34. >>= loadAndApplyTemplate "templates/archive.html" archiveCtx
  35. >>= loadAndApplyTemplate "templates/default.html" archiveCtx
  36. >>= relativizeUrls
  37. match "index.html" $ do
  38. route idRoute
  39. compile $ do
  40. posts <- recentFirst =<< loadAll "posts/*"
  41. let indexCtx =
  42. listField "posts" postCtx (return posts) `mappend`
  43. constField "title" "home" `mappend`
  44. defaultContext
  45. getResourceBody
  46. >>= applyAsTemplate indexCtx
  47. >>= loadAndApplyTemplate "templates/default.html" indexCtx
  48. >>= relativizeUrls
  49. match "templates/*" $ compile templateBodyCompiler
  50. --------------------------------------------------------------------------------
  51. postCtx :: Context String
  52. postCtx =
  53. dateField "date" "%Y年 %m月 %d日" `mappend`
  54. defaultContext