website/site.hs
mangoiv daca65f952
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
[chore] add numbering for haskell-tooling post
2024-06-23 14:08:06 +02:00

98 lines
2.8 KiB
Haskell

{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE OverloadedLists #-}
{-# LANGUAGE OverloadedStrings #-}
import Control.Monad.IO.Class (MonadIO (liftIO))
import Data.ByteString.Lazy qualified as BS
import Hakyll
import Skylighting.Styles
import Text.Pandoc.Highlighting
import Text.Pandoc.Options
--------------------------------------------------------------------------------
main :: IO ()
main = do
hakyll do
match "images/*" do
route idRoute
compile copyFileCompiler
match "css/*" do
route idRoute
compile compressCssCompiler
match "css/fonts/*" do
route idRoute
compile copyFileCompiler
match "robots.txt" do
route idRoute
compile copyFileCompiler
match "js/*" do
route idRoute
compile copyFileCompiler
match "about.md" do
route $ setExtension "html"
compile $
pandocCompiler
>>= loadAndApplyTemplate "templates/default.html" defaultContext
>>= relativizeUrls
match "themes/dracula.json" do
route (constRoute "css/syntax-dark.css")
compile do
Right draculaTheme <- traverse parseTheme <$> getResourceLBS
pure $ styleToCss <$> draculaTheme
match "themes/latte.json" do
route (constRoute "css/syntax-light.css")
compile do
Right latteTheme <- traverse parseTheme <$> getResourceLBS
pure $ styleToCss <$> latteTheme
create ["posts.html"] do
route idRoute
compile do
posts <- recentFirst =<< loadAll "posts/*"
let archiveCtx =
mconcat
[ listField "posts" postCtx (return posts)
, constField "title" "Archives"
, defaultContext
]
makeItem ""
>>= loadAndApplyTemplate "templates/archive.html" archiveCtx
>>= loadAndApplyTemplate "templates/default.html" archiveCtx
>>= relativizeUrls
match "posts/*" do
route $ setExtension "html"
compile $
pandocCompilerWith defaultHakyllReaderOptions {readerExtensions = pandocExtensions} defaultHakyllWriterOptions
>>= loadAndApplyTemplate "templates/post.html" postCtx
>>= loadAndApplyTemplate "templates/default.html" postCtx
>>= relativizeUrls
match "index.html" do
route idRoute
compile do
posts <- recentFirst =<< loadAll "posts/*"
let indexCtx =
listField "posts" postCtx (return posts)
<> defaultContext
getResourceBody
>>= applyAsTemplate indexCtx
>>= loadAndApplyTemplate "templates/default.html" indexCtx
>>= relativizeUrls
match "templates/*" $ compile templateBodyCompiler
--------------------------------------------------------------------------------
postCtx :: Context String
postCtx =
dateField "date" "%B %e, %Y"
<> defaultContext