From f6c73cf906f17b3df2945f3577d577679112b9d2 Mon Sep 17 00:00:00 2001 From: "Niels G. W. Serup" Date: Mon, 30 Sep 2024 23:31:16 +0200 Subject: [PATCH] Make generator run --- byg/src/SiteGenerator.hs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/byg/src/SiteGenerator.hs b/byg/src/SiteGenerator.hs index 834fa20..50efd71 100644 --- a/byg/src/SiteGenerator.hs +++ b/byg/src/SiteGenerator.hs @@ -24,13 +24,13 @@ makeImageHTML t = do (toText thumbnail) (inject "\">

")))) -handleRecipeDir :: Token FilePath -> Token Template -> Token FilePath -> Token FilePath -> DepGenM () -handleRecipeDir outputDir template indexName dir = do - recipeDirOut <- joinPaths outputDir dir +handleRecipeDir :: Token FilePath -> Token FilePath -> Token Template -> Token FilePath -> Token FilePath -> DepGenM () +handleRecipeDir inputDir outputDir template indexName name = do + dir <- joinPaths inputDir name + recipeDirOut <- joinPaths outputDir name makeDir recipeDirOut dirContents <- listDirectory dir - areImageFilenames <- mapDepGenM hasImageExtension - $ unzipSndDepGenM $ mapDepGenM fileComponents dirContents + areImageFilenames <- mapDepGenM hasImageExtension dirContents imageFilenames <- filterDepGenM areImageFilenames dirContents imagePaths <- mapDepGenM (joinPaths dir) imageFilenames imagePathsOut <- mapDepGenM (joinPaths recipeDirOut) imageFilenames @@ -56,8 +56,11 @@ generateSite = do makeDir outputRecipesDir template <- readTemplate $ inject "template.html" indexName <- inject "index.html" - dirContents <- listDirectory recipesDir - mapDepGenM_ (handleRecipeDir outputRecipesDir template indexName) dirContents + dirNames <- listDirectory recipesDir + dirPaths <- mapDepGenM (joinPaths recipesDir) dirNames + dirPathsAreSubdirs <- mapDepGenM isDirectory dirPaths + dirNames' <- filterDepGenM dirPathsAreSubdirs dirNames + mapDepGenM_ (handleRecipeDir recipesDir outputRecipesDir template indexName) dirNames' html <- applyTemplate template $ runPandoc $ inject "om.md" aboutDir <- joinPaths outputDir $ inject "om" makeDir aboutDir