parent
0e98373389
commit
e51e7a5376
|
@ -1,6 +1,6 @@
|
|||
module SiteGenerator (generateSite) where
|
||||
|
||||
import Types (Token)
|
||||
import Types (Token(..))
|
||||
import DependencyGenerator
|
||||
import Functions
|
||||
|
||||
|
@ -8,7 +8,7 @@ import Data.Text (Text)
|
|||
import qualified Data.Text as T
|
||||
import Control.Monad (forM_)
|
||||
|
||||
handleRecipeDir :: Token FilePath -> Token Template -> Token FilePath -> Token FilePath -> DepGenM (Token Text)
|
||||
handleRecipeDir :: Token FilePath -> Token Template -> Token FilePath -> Token FilePath -> DepGenM (Token (Text, FilePath))
|
||||
handleRecipeDir outputDir htmlTemplate indexName dir = do
|
||||
recipeDirOut <- joinPaths outputDir dir
|
||||
makeDir recipeDirOut
|
||||
|
@ -42,7 +42,7 @@ handleRecipeDir outputDir htmlTemplate indexName dir = do
|
|||
html <- applyTemplate htmlTemplate
|
||||
$ writeHtml pandoc
|
||||
saveTextFile html (joinPaths recipeDirOut indexName)
|
||||
pure title
|
||||
pure $ TupleToken title dir
|
||||
|
||||
handleFontDir :: Token FilePath -> Token FilePath -> DepGenM ()
|
||||
handleFontDir outputDir dir = do
|
||||
|
@ -61,12 +61,17 @@ generateSite = do
|
|||
|
||||
-- Handle recipes
|
||||
recipesDir <- inject "retter"
|
||||
makeDir $ joinPaths outputDir recipesDir
|
||||
outputRecipesDir <- joinPaths outputDir recipesDir
|
||||
makeDir $ outputRecipesDir
|
||||
recipeSubDirs <- filterDepGenM isDirectory
|
||||
$ mapDepGenM (joinPaths recipesDir)
|
||||
$ listDirectory recipesDir
|
||||
_titles <- mapDepGenM (handleRecipeDir outputDir htmlTemplate indexName) recipeSubDirs
|
||||
-- TODO: Use titles
|
||||
infos <- mapDepGenM (handleRecipeDir outputDir htmlTemplate indexName) recipeSubDirs
|
||||
allRecipesHtml <- applyTemplate htmlTemplate
|
||||
$ writeHtml
|
||||
$ readMarkdown
|
||||
$ onToken (T.append "# Alle retter\n\n" . T.intercalate "\n" . map (\(t, u) -> T.concat ["- ", "[", t, "](/", T.pack u, ")"])) infos
|
||||
saveTextFile allRecipesHtml (joinPaths outputRecipesDir indexName)
|
||||
|
||||
-- Handle about page
|
||||
outputAboutDir <- joinPaths outputDir (inject "om")
|
||||
|
|
Loading…
Reference in New Issue