Also build every recipe html page
This commit is contained in:
parent
daacf2e6fa
commit
4a0ea4d5ef
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue