mad/byg/src/SiteGenerator.hs

29 lines
978 B
Haskell
Raw Normal View History

2024-09-23 22:11:54 +02:00
module SiteGenerator (generateSite) where
import Types
import DependencyGenerator
handleRecipeDir :: Token Template -> Token FilePath -> DepGenM ()
handleRecipeDir _template dir = do
dirContents <- listDirectory dir
imageFilenames <- filterDepGenM isImageFilename dirContents
convertedImageFilenames <- mapDepGenM convertedImageFilename imageFilenames
flip mapDepGenM_ (ZipToken imageFilenames convertedImageFilenames) $ \files -> do
settings <- inject $ ResizeToWidth 800
convertImage $ TupleToken files settings
2024-09-24 22:38:52 +02:00
pure NoToken
2024-09-23 22:11:54 +02:00
generateSite :: DepGenM ()
generateSite = do
2024-09-24 22:38:52 +02:00
outputDir <- inject "site"
makeDir outputDir
2024-09-23 22:11:54 +02:00
templateFilename <- inject "template.html"
template <- readTemplate templateFilename
dir <- inject "retter"
dirContents <- listDirectory dir
mapDepGenM_ (handleRecipeDir template) dirContents
2024-09-24 22:38:52 +02:00
aboutFilenameIn <- inject "om.md"
aboutFilenameOut <- inject "om.html"
runPandoc $ TupleToken aboutFilenameIn aboutFilenameOut