From d201cf8b1bfe5b03a6eb3f12e4514c398869845c Mon Sep 17 00:00:00 2001 From: "Yann Esposito (Yogsototh)" Date: Tue, 23 Jun 2020 08:44:02 +0200 Subject: [PATCH] wip --- Shakefile.hs | 11 ++++++++++- templates/main.mustache | 14 +------------- templates/post.html | 4 +--- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/Shakefile.hs b/Shakefile.hs index 6deb93d..948fb3f 100644 --- a/Shakefile.hs +++ b/Shakefile.hs @@ -22,6 +22,7 @@ import Text.Pandoc.Definition ( Pandoc(..) , Inline , nullMeta , docTitle + , lookupMeta , docDate , docAuthors ) @@ -59,6 +60,7 @@ data BlogPost = , postAuthors :: [T.Text] , postUrl :: FilePath , postBody :: Pandoc + -- , postToc :: Boolean } inlineToText :: PandocMonad m => [Inline] -> m T.Text @@ -72,7 +74,6 @@ getBlogpostFromMetas path pandoc@(Pandoc meta _) = do title <- inlineToText $ docTitle meta date <- inlineToText $ docDate meta authors <- mapM inlineToText $ docAuthors meta - -- let url = dropExtension path return $ BlogPost title date authors path pandoc case eitherBlogpost of Left _ -> fail "BAD" @@ -146,9 +147,17 @@ mkGetTemplate = newCache $ \path -> do Left _ -> fail "BAD" Right template -> return template +parseOptions :: Text -> [Text] -> Maybe Text +parseOptions fc = + fc & T.lines + & map T.toLower + & filter (T.isPrefixOf (T.pack "#options: ")) + & head + mkGetPost :: Rules (FilePath -> Action BlogPost) mkGetPost = newCache $ \path -> do fileContent <- readFile' path + let options = parseOptions (toS fileContent) eitherResult <- liftIO $ Pandoc.runIO $ Readers.readOrg def (toS fileContent) case eitherResult of Left _ -> fail "BAD" diff --git a/templates/main.mustache b/templates/main.mustache index 5b38e62..a94c624 100644 --- a/templates/main.mustache +++ b/templates/main.mustache @@ -33,22 +33,10 @@

{{title}}

-

-

-

{{{ body }}} +