summaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2010-01-17 21:42:52 +0100
committerJasper Van der Jeugt <jaspervdj@gmail.com>2010-01-17 21:42:52 +0100
commit10dd6dafc0cde5262da667abe7e93477688550eb (patch)
tree1c4f1402ead511b8560169c86797e6bd2a0982bf /src/Text
parentfb381ddfd3a359ae85cd3fa0e8a0ad6ba3676631 (diff)
downloadhakyll-10dd6dafc0cde5262da667abe7e93477688550eb.tar.gz
Added section metadata writing.
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Hakyll/Page.hs9
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