summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hakyll.cabal1
-rw-r--r--src/Text/Hakyll/Page.hs10
-rw-r--r--src/Text/Hakyll/Render.hs12
3 files changed, 17 insertions, 6 deletions
diff --git a/hakyll.cabal b/hakyll.cabal
index 02cf98e..ece4b13 100644
--- a/hakyll.cabal
+++ b/hakyll.cabal
@@ -7,6 +7,7 @@ Description:
creating blogs.
Author: Jasper Van der Jeugt
Maintainer: jaspervdj@gmail.com
+Homepage: http://github.com/jaspervdj/Hakyll
License: BSD3
License-File: LICENSE
Category: Text
diff --git a/src/Text/Hakyll/Page.hs b/src/Text/Hakyll/Page.hs
index 7219f1a..dcb9c97 100644
--- a/src/Text/Hakyll/Page.hs
+++ b/src/Text/Hakyll/Page.hs
@@ -51,11 +51,11 @@ writerOptions = defaultWriterOptions
renderFunction :: String -> (String -> String)
renderFunction ".html" = id
renderFunction ext = writeHtmlString writerOptions .
- renderFunction' ext defaultParserState
- where renderFunction' ".markdown" = readMarkdown
- renderFunction' ".md" = readMarkdown
- renderFunction' ".tex" = readLaTeX
- renderFunction' _ = readMarkdown
+ readFunction ext defaultParserState
+ where readFunction ".markdown" = readMarkdown
+ readFunction ".md" = readMarkdown
+ readFunction ".tex" = readLaTeX
+ readFunction _ = readMarkdown
readMetaData :: Handle -> IO [(String, String)]
readMetaData handle = do
diff --git a/src/Text/Hakyll/Render.hs b/src/Text/Hakyll/Render.hs
index a69d27d..79f8764 100644
--- a/src/Text/Hakyll/Render.hs
+++ b/src/Text/Hakyll/Render.hs
@@ -1,6 +1,7 @@
module Text.Hakyll.Render
( renderPage,
renderAndWrite,
+ renderAndConcat,
static,
staticDirectory
) where
@@ -26,7 +27,7 @@ renderPage templatePath page = do
templateString <- liftM B.pack $ hGetContents handle
seq templateString $ hClose handle
let body = substitute templateString (createContext page)
- return $ addContext "body" (B.unpack body) page
+ return $ M.insert "body" body page
renderAndWrite :: FilePath -> Page -> IO ()
renderAndWrite templatePath page = do
@@ -35,6 +36,15 @@ renderAndWrite templatePath page = do
makeDirectories destination
B.writeFile destination (getBody rendered)
+renderAndConcat :: FilePath -> [FilePath] -> IO B.ByteString
+renderAndConcat templatePath paths = foldM concatRender' B.empty paths
+ where concatRender' :: B.ByteString -> FilePath -> IO B.ByteString
+ concatRender' chunk path = do
+ page <- readPage path
+ rendered <- renderPage templatePath page
+ let body = getBody rendered
+ return $ B.append chunk $ body
+
static :: FilePath -> IO ()
static source = do
makeDirectories destination