2024-09-23 22:11:54 +02:00
|
|
|
module SiteGenerator (generateSite) where
|
|
|
|
|
|
|
|
import Types
|
|
|
|
import DependencyGenerator
|
|
|
|
|
2024-09-24 23:01:07 +02:00
|
|
|
handleRecipeDir :: Token Template -> Token FilePath -> DepGenM' ()
|
2024-09-23 22:11:54 +02:00
|
|
|
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 23:01:07 +02:00
|
|
|
generateSite :: DepGenM' ()
|
2024-09-23 22:11:54 +02:00
|
|
|
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 23:01:07 +02:00
|
|
|
aboutPathIn <- inject "om.md"
|
|
|
|
aboutHtmlBody <- runPandoc aboutPathIn
|
|
|
|
aboutHtml <- applyTemplate $ TupleToken template aboutHtmlBody
|
2024-09-24 22:38:52 +02:00
|
|
|
aboutFilenameOut <- inject "om.html"
|
2024-09-24 23:01:07 +02:00
|
|
|
aboutPathOut <- joinPaths $ TupleToken outputDir aboutFilenameOut
|
|
|
|
saveFile $ TupleToken aboutHtml aboutPathOut
|