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.

83 lines
2.5KB

  1. --------------------------------------------------------------------------------
  2. {-# LANGUAGE OverloadedStrings #-}
  3. import Data.Monoid ((<>))
  4. import Hakyll
  5. import Hakyll.Favicon (faviconsRules, faviconsField)
  6. --------------------------------------------------------------------------------
  7. muraConf :: Configuration
  8. muraConf = defaultConfiguration
  9. { destinationDirectory = "_http"
  10. , storeDirectory = "_store"
  11. , tmpDirectory = "_tmp"
  12. , providerDirectory = "_input"
  13. }
  14. -- Our default context for pages
  15. ctx :: Context String
  16. ctx = defaultContext <>
  17. faviconsField
  18. main :: IO ()
  19. main = hakyllWith muraConf $ do
  20. faviconsRules "icons/favicon.svg"
  21. match "images/*" $ do
  22. route idRoute
  23. compile copyFileCompiler
  24. match "css/*" $ do
  25. route idRoute
  26. compile compressCssCompiler
  27. match (fromList ["about.md", "contact.markdown"]) $ do
  28. route $ setExtension "html"
  29. compile $ pandocCompiler
  30. >>= loadAndApplyTemplate "templates/default.html" ctx
  31. >>= relativizeUrls
  32. match "posts/*" $ do
  33. route $ setExtension "html"
  34. compile $ pandocCompiler
  35. >>= loadAndApplyTemplate "templates/post.html" postCtx
  36. >>= loadAndApplyTemplate "templates/default.html" postCtx
  37. >>= relativizeUrls
  38. create ["archive.html"] $ do
  39. route idRoute
  40. compile $ do
  41. posts <- recentFirst =<< loadAll "posts/*"
  42. let archiveCtx =
  43. listField "posts" postCtx (return posts) <>
  44. constField "title" "archives" <>
  45. ctx
  46. makeItem ""
  47. >>= loadAndApplyTemplate "templates/archive.html" archiveCtx
  48. >>= loadAndApplyTemplate "templates/default.html" archiveCtx
  49. >>= relativizeUrls
  50. match "index.html" $ do
  51. route idRoute
  52. compile $ do
  53. posts <- recentFirst =<< loadAll "posts/*"
  54. let indexCtx =
  55. listField "posts" postCtx (return posts) <>
  56. constField "title" "ホームページ" <>
  57. ctx
  58. getResourceBody
  59. >>= applyAsTemplate indexCtx
  60. >>= loadAndApplyTemplate "templates/default.html" indexCtx
  61. >>= relativizeUrls
  62. match "templates/*" $ compile templateBodyCompiler
  63. --------------------------------------------------------------------------------
  64. postCtx :: Context String
  65. postCtx =
  66. dateField "date" "%Y年%-m月%-d日" <>
  67. ctx