@@ -1,6 +1,7 @@
1module Text.Hakyll.Render
1module Text.Hakyll.Render
2 ( renderPage,
2 ( renderPage,
3 renderAndWrite,
3 renderAndWrite,
5 staticDirectory
6 staticDirectory
@@ -26,7 +27,7 @@ renderPage templatePath page = do
26 templateString <- liftM B.pack $ hGetContents handle
27 templateString <- liftM B.pack $ hGetContents handle
27 seq templateString $ hClose handle
28 seq templateString $ hClose handle
28 let body = substitute templateString (createContext page)
29 let body = substitute templateString (createContext page)
29− return $ addContext "body" (B.unpack body) page
30+ return $ M.insert "body" body page
31renderAndWrite :: FilePath -> Page -> IO ()
32renderAndWrite :: FilePath -> Page -> IO ()
32renderAndWrite templatePath page = do
33renderAndWrite templatePath page = do
@@ -35,6 +36,15 @@ renderAndWrite templatePath page = do
35 makeDirectories destination
36 makeDirectories destination
36 B.writeFile destination (getBody rendered)
37 B.writeFile destination (getBody rendered)
39+renderAndConcat :: FilePath -> [FilePath] -> IO B.ByteString
40+renderAndConcat templatePath paths = foldM concatRender' B.empty paths
41+ where concatRender' :: B.ByteString -> FilePath -> IO B.ByteString
42+ concatRender' chunk path = do
43+ page <- readPage path
44+ rendered <- renderPage templatePath page
45+ let body = getBody rendered
46+ return $ B.append chunk $ body
38static :: FilePath -> IO ()
48static :: FilePath -> IO ()
39static source = do
49static source = do
40 makeDirectories destination
50 makeDirectories destination