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