From 10dd6dafc0cde5262da667abe7e93477688550eb Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Sun, 17 Jan 2010 21:42:52 +0100 Subject: Added section metadata writing. --- src/Text/Hakyll/Page.hs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/Text/Hakyll') diff --git a/src/Text/Hakyll/Page.hs b/src/Text/Hakyll/Page.hs index 8c0a7de..db5360d 100644 --- a/src/Text/Hakyll/Page.hs +++ b/src/Text/Hakyll/Page.hs @@ -86,10 +86,14 @@ cachePage page@(Page mapping) = do makeDirectories destination liftIO writePageToCache where + (sectionMetaData, simpleMetaData) = M.partition (not . elem '\n') + (M.delete "body" mapping) + writePageToCache = do handle <- openFile destination WriteMode hPutStrLn handle "---" - mapM_ (writePair handle) $ M.toList $ M.delete "body" mapping + mapM_ (writePair handle) $ M.toList simpleMetaData + mapM_ (writeSection handle) $ M.toList sectionMetaData hPutStrLn handle "---" hPutStr handle $ getBody page hClose handle @@ -97,6 +101,9 @@ cachePage page@(Page mapping) = do writePair h (k, v) = do hPutStr h $ k ++ ": " ++ v hPutStrLn h "" + writeSection h (k, v) = do hPutStrLn h $ "--- " ++ k + hPutStrLn h v + destination = toCache $ getURL page -- | Read a page from a file. Metadata is supported, and if the filename -- cgit v1.2.3