diff options
Diffstat (limited to 'src/Text/Hakyll')
-rw-r--r-- | src/Text/Hakyll/Page.hs | 9 |
1 files changed, 8 insertions, 1 deletions
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 |