diff options
author | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2010-01-14 20:46:08 +0100 |
---|---|---|
committer | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2010-01-14 20:46:08 +0100 |
commit | 4bc34b8a98ffa1e7f3478a596b73c4ab12d9cb1b (patch) | |
tree | 86ff0e311ec49f794b28f973c95620918ab4f9ee /src/Text/Hakyll.hs | |
parent | 332f2f95cdb9c72e01a55eaf46c0b08bcf37d7e9 (diff) | |
download | hakyll-4bc34b8a98ffa1e7f3478a596b73c4ab12d9cb1b.tar.gz |
Added ReaderT to our stack.
Diffstat (limited to 'src/Text/Hakyll.hs')
-rw-r--r-- | src/Text/Hakyll.hs | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/src/Text/Hakyll.hs b/src/Text/Hakyll.hs index e23e211..2586c02 100644 --- a/src/Text/Hakyll.hs +++ b/src/Text/Hakyll.hs @@ -1,28 +1,42 @@ module Text.Hakyll - ( hakyll + ( defaultHakyllConfiguration + , hakyll ) where +import Control.Monad.Reader (runReaderT) +import qualified Data.Map as M + import Network.Hakyll.SimpleServer (simpleServer) +import Text.Hakyll.Hakyll import System.Environment (getArgs, getProgName) import System.Directory (doesDirectoryExist, removeDirectoryRecursive) +-- | Default hakyll configuration. +defaultHakyllConfiguration :: HakyllConfiguration +defaultHakyllConfiguration = HakyllConfiguration + { hakyllDestination = "_site" + , hakyllGlobalContext = M.empty + } + -- | Main function to run hakyll. -hakyll :: IO () -> IO () -hakyll buildFunction = do +hakyll :: HakyllConfiguration -> Hakyll () -> IO () +hakyll configuration buildFunction = do args <- getArgs - case args of ["build"] -> build buildFunction + case args of ["build"] -> build' ["clean"] -> clean - ["preview", p] -> build buildFunction >> server (read p) - ["preview"] -> build buildFunction >> server 8000 + ["preview", p] -> build' >> server (read p) + ["preview"] -> build' >> server 8000 ["server", p] -> server (read p) ["server"] -> server 8000 _ -> help + where + build' = build configuration buildFunction -- | Build the site. -build :: IO () -> IO () -build buildFunction = do putStrLn "Generating..." - buildFunction +build :: HakyllConfiguration -> Hakyll () -> IO () +build configuration buildFunction = do putStrLn "Generating..." + runReaderT buildFunction configuration -- | Clean up directories. clean :: IO () |