module SiteGenerator (generateSite) where import Types import DependencyGenerator handleRecipeDir :: Token Template -> Token FilePath -> DepGenM' () 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 generateSite :: DepGenM' () generateSite = do outputDir <- inject "site" makeDir outputDir templateFilename <- inject "template.html" template <- readTemplate templateFilename dir <- inject "retter" dirContents <- listDirectory dir mapDepGenM_ (handleRecipeDir template) dirContents aboutPathIn <- inject "om.md" aboutHtmlBody <- runPandoc aboutPathIn aboutHtml <- applyTemplate $ TupleToken template aboutHtmlBody aboutFilenameOut <- inject "om.html" aboutPathOut <- joinPaths $ TupleToken outputDir aboutFilenameOut saveFile $ TupleToken aboutHtml aboutPathOut