From 4a0ea4d5ef3e453f52e5e1a0594e8c247e8657be Mon Sep 17 00:00:00 2001 From: "Niels G. W. Serup" Date: Wed, 25 Sep 2024 19:37:49 +0200 Subject: [PATCH] Also build every recipe html page --- byg/src/SiteGenerator.hs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/byg/src/SiteGenerator.hs b/byg/src/SiteGenerator.hs index 06e4dd1..b55dcae 100644 --- a/byg/src/SiteGenerator.hs +++ b/byg/src/SiteGenerator.hs @@ -3,14 +3,23 @@ module SiteGenerator (generateSite) where import Types import DependencyGenerator -handleRecipeDir :: Token Template -> Token FilePath -> DepGenM () -handleRecipeDir _template dir = do +handleRecipeDir :: Token FilePath -> Token Template -> Token FilePath -> DepGenM () +handleRecipeDir outputDir 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 + recipeFilenameIn <- inject "ret.md" + recipePathIn <- joinPaths $ TupleToken dir recipeFilenameIn + recipeDirOut <- joinPaths $ TupleToken outputDir dir + makeDir recipeDirOut + recipeFilenameOut <- inject "index.html" + recipePathOut <- joinPaths $ TupleToken recipeDirOut recipeFilenameOut + htmlBody <- runPandoc recipePathIn + html <- applyTemplate $ TupleToken template htmlBody + saveFile $ TupleToken html recipePathOut generateSite :: DepGenM () generateSite = do @@ -20,11 +29,11 @@ generateSite = do template <- readTemplate templateFilename dir <- inject "retter" dirContents <- listDirectory dir - mapDepGenM_ (handleRecipeDir template) dirContents + mapDepGenM_ (handleRecipeDir outputDir template) dirContents aboutPathIn <- inject "om.md" - aboutHtmlBody <- runPandoc aboutPathIn - aboutHtml <- applyTemplate $ TupleToken template aboutHtmlBody aboutFilenameOut <- inject "om.html" aboutPathOut <- joinPaths $ TupleToken outputDir aboutFilenameOut + aboutHtmlBody <- runPandoc aboutPathIn + aboutHtml <- applyTemplate $ TupleToken template aboutHtmlBody saveFile $ TupleToken aboutHtml aboutPathOut