Go a more direct route with the recipes dirs

This commit is contained in:
Niels G. W. Serup 2024-10-05 20:35:34 +02:00
parent 9240d66c15
commit 90a968ea7d
No known key found for this signature in database
GPG Key ID: 38EEEBCE67324F19
1 changed files with 6 additions and 8 deletions

View File

@ -29,10 +29,9 @@ hasExtension exts filename = do
ext <- lowerString $ untupleSndDepGenM $ fileComponents filename
ext `elemOf` exts
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
handleRecipeDir :: Token FilePath -> Token Template -> Token FilePath -> Token FilePath -> DepGenM ()
handleRecipeDir outputDir template indexName dir = do
recipeDirOut <- joinPaths outputDir dir
makeDir recipeDirOut
dirContents <- listDirectory dir
areImageFilenames <- mapDepGenM (hasExtension $ inject ["jpg"]) dirContents
@ -65,15 +64,14 @@ generateSite = do
outputDir <- inject "site"
makeDir outputDir
recipesDir <- inject "retter"
outputRecipesDir <- joinPaths outputDir recipesDir
makeDir outputRecipesDir
makeDir $ joinPaths outputDir recipesDir
template <- makeTemplate (readTextFile (inject "template.html")) (inject "CONTENT")
indexName <- inject "index.html"
dirNames <- listDirectory recipesDir
dirPaths <- mapDepGenM (joinPaths recipesDir) dirNames
dirPathsAreSubdirs <- mapDepGenM isDirectory dirPaths
dirNames' <- filterDepGenM dirPathsAreSubdirs dirNames
mapDepGenM_ (handleRecipeDir recipesDir outputRecipesDir template indexName) dirNames'
dirPaths' <- filterDepGenM dirPathsAreSubdirs dirPaths
mapDepGenM_ (handleRecipeDir outputDir template indexName) dirPaths'
html <- applyTemplate template $ runPandoc $ readTextFile $ inject "om.md"
aboutDir <- joinPaths outputDir $ inject "om"
makeDir aboutDir