Commit c21d04e2 authored by Nicolas Lenz's avatar Nicolas Lenz ❄️
Browse files

Clean up

parent 1716ed16
Loading
Loading
Loading
Loading
Loading
+1 −22
Original line number Diff line number Diff line
@@ -4,7 +4,6 @@ module Build (build) where

import ClassyPrelude hiding ((</>))
import Config
import Control.Monad.Catch
import Path
import Path.IO
import System.Process
@@ -156,27 +155,6 @@ generateSummary path (Pandoc meta body) = Summary
addMeta :: Meta -> Pandoc -> Pandoc
addMeta (Meta metaMapExtra) (Pandoc (Meta metaMap) blocks) = Pandoc (Meta $ metaMapExtra `Map.union` metaMap) blocks

-- | Extracts the title attribute from a Pandoc and returns it as plain text.
titleString :: Pandoc -> Text
titleString (Pandoc meta _) = case runPure $ writePlain def $ Pandoc nullMeta [Plain $ docTitle meta] of
    Left _ -> "Untitled"
    Right title -> title

{- processPages :: (PandocMonad m, MonadIO m) => Config -> FilePath -> m ()
processPages Config {..} basePath = do
    wo <- writerOptions configTemplatePage
    writeFolder wo (basePath </> "out" </> "page") =<< parseMarkdowns =<< readFolder (basePath </> "page")

processArticles :: (PandocMonad m, MonadIO m) => Config -> FilePath -> m ()
processArticles Config {..} basePath = do
    articles' <- parseMarkdowns =<< readFolder (basePath </> "article")
    let articles = map setTitleFromHeader articles'
    let abstracts = sconcat $ NonEmpty.fromList $ map getAbstract articles
    wo <- liftIO $ writerOptions configTemplateArticle
    writeFolder wo (basePath </> "out" </> "article") articles
    wo <- liftIO $ writerOptions configTemplateIndex
    Read.writeFile wo (basePath </> "out") abstracts -}

copyFolders :: Config -> IO ()
copyFolders Config{..} = do
    folders <- mapM parseRelDir configFoldersToCopy
@@ -206,5 +184,6 @@ build = loadConfig >>= \case
            Left ex -> fail $ "Error while processing articles: " <> show ex
            Right (indexOutput, articlesOutput, pagesOutput) -> do
                save [reldir|out/article|] articlesOutput
                save [reldir|out|] pagesOutput
                writeFileUtf8 "out/index.html" indexOutput
                putStrLn "Success!"