The source code of blog.fyber.space https://blog.fyber.space
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.

site.hs 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. {-
  2. - File : site.hs
  3. - Author : Vincent Truchseß <redtux@posteo.net>
  4. - Date : 04.04.2019
  5. - Last Modified Date: 04.04.2019
  6. - Last Modified By : Vincent Truchseß <redtux@posteo.net>
  7. -}
  8. --------------------------------------------------------------------------------
  9. {-# LANGUAGE OverloadedStrings #-}
  10. import Data.Monoid (mappend)
  11. import Hakyll
  12. --------------------------------------------------------------------------------
  13. main :: IO ()
  14. main = hakyllWith config $ do
  15. match "images/*" $ do
  16. route idRoute
  17. compile copyFileCompiler
  18. match "files/*" $ do
  19. route idRoute
  20. compile copyFileCompiler
  21. match "css/*" $ do
  22. route idRoute
  23. compile compressCssCompiler
  24. match "favicon.png" $ do
  25. route idRoute
  26. compile copyFileCompiler
  27. match (fromList ["about.md", "contact.md"]) $ do
  28. route $ setExtension "html"
  29. compile $ pandocCompiler
  30. >>= loadAndApplyTemplate "templates/default.html" defaultContext
  31. >>= relativizeUrls
  32. match "posts/*" $ do
  33. route $ setExtension "html"
  34. compile $ pandocCompiler
  35. >>= loadAndApplyTemplate "templates/post.html" postCtx
  36. >>= saveSnapshot "content"
  37. >>= loadAndApplyTemplate "templates/default.html" postCtx
  38. >>= relativizeUrls
  39. create ["archive.html"] $ do
  40. route idRoute
  41. compile $ do
  42. posts <- recentFirst =<< loadAll "posts/*"
  43. let archiveCtx =
  44. listField "posts" postCtx (return posts) `mappend`
  45. constField "title" "Archives" `mappend`
  46. defaultContext
  47. makeItem ""
  48. >>= loadAndApplyTemplate "templates/archive.html" archiveCtx
  49. >>= loadAndApplyTemplate "templates/default.html" archiveCtx
  50. >>= relativizeUrls
  51. match "index.html" $ do
  52. route idRoute
  53. compile $ do
  54. posts <- recentFirst =<< loadAll "posts/*"
  55. let indexCtx =
  56. listField "posts" postCtx (return posts) `mappend`
  57. constField "title" "Home" `mappend`
  58. defaultContext
  59. getResourceBody
  60. >>= applyAsTemplate indexCtx
  61. >>= loadAndApplyTemplate "templates/default.html" indexCtx
  62. >>= relativizeUrls
  63. match "templates/*" $ compile templateBodyCompiler
  64. create ["rss.xml"] $ do
  65. route idRoute
  66. compile $ do
  67. -- let feedCtx = postCtx `mappend`
  68. -- constField "description" "This is the post description"
  69. posts <- fmap (take 20) . recentFirst =<< loadAllSnapshots "posts/*" "content"
  70. renderRss myFeedConfiguration feedCtx posts
  71. --------------------------------------------------------------------------------
  72. postCtx :: Context String
  73. postCtx =
  74. dateField "date" "%B %e, %Y" `mappend`
  75. defaultContext
  76. feedCtx :: Context String
  77. feedCtx = postCtx <> bodyField "description"
  78. myFeedConfiguration :: FeedConfiguration
  79. myFeedConfiguration = FeedConfiguration
  80. { feedTitle = "FyberSpace"
  81. , feedDescription = "VI's Blog"
  82. , feedAuthorName = "VI"
  83. , feedAuthorEmail = ""
  84. , feedRoot = "https://blog.fyber.space"
  85. }
  86. config = defaultConfiguration
  87. { deployCommand = "rsync -r _site/ leviathan:/var/www/blog/"
  88. }