on master help sign in
Added section metadata writing.
commit10dd6dafc0cde5262da667abe7e93477688550eb authorJasper Van der Jeugt <jaspervdj@gmail.com> dateSun 17 Jan 2010, 21:42 (17 years ago) parentfb381dd
1 file changed+8−1
src/Text/Hakyll/Page.hs+8−1
src/Text/Hakyll/Page.hs+8−1
@@ -86,10 +86,14 @@ cachePage page@(Page mapping) = do
8686 makeDirectories destination
8787 liftIO writePageToCache
8888 where
89+ (sectionMetaData, simpleMetaData) = M.partition (not . elem '\n')
90+ (M.delete "body" mapping)
91+
8992 writePageToCache = do
9093 handle <- openFile destination WriteMode
9194 hPutStrLn handle "---"
92− mapM_ (writePair handle) $ M.toList $ M.delete "body" mapping
95+ mapM_ (writePair handle) $ M.toList simpleMetaData
96+ mapM_ (writeSection handle) $ M.toList sectionMetaData
9397 hPutStrLn handle "---"
9498 hPutStr handle $ getBody page
9599 hClose handle
@@ -97,6 +101,9 @@ cachePage page@(Page mapping) = do
97101 writePair h (k, v) = do hPutStr h $ k ++ ": " ++ v
98102 hPutStrLn h ""
99103
104+ writeSection h (k, v) = do hPutStrLn h $ "--- " ++ k
105+ hPutStrLn h v
106+
100107 destination = toCache $ getURL page
101108
102109-- | Read a page from a file. Metadata is supported, and if the filename