on master help sign in
A little more documentation.
fbd9ff9Jasper Van der Jeugt
src/Text/Hakyll.hs+13−3
@@ -1,3 +1,12 @@
1+-- | This is the main Hakyll module, exporting the important @hakyl@ function.
2+--
3+-- Most configurations would use this @hakyll@ function more or less as the
4+-- main function:
5+--
6+-- > main = hakyll $ do
7+-- > directory css "css"
8+-- > directory static "images"
9+--
1module Text.Hakyll
10module Text.Hakyll
2 ( defaultHakyllConfiguration
11 ( defaultHakyllConfiguration
3 , hakyll
12 , hakyll
@@ -13,7 +22,7 @@ import System.Directory (doesDirectoryExist, removeDirectoryRecursive)
13import Network.Hakyll.SimpleServer (simpleServer)
22import Network.Hakyll.SimpleServer (simpleServer)
14import Text.Hakyll.Hakyll
23import Text.Hakyll.Hakyll
15
24
16−-- | Default hakyll configuration.
25+-- | The default hakyll configuration.
17defaultHakyllConfiguration :: HakyllConfiguration
26defaultHakyllConfiguration :: HakyllConfiguration
18defaultHakyllConfiguration = HakyllConfiguration
27defaultHakyllConfiguration = HakyllConfiguration
19 { additionalContext = M.empty
28 { additionalContext = M.empty
@@ -21,11 +30,11 @@ defaultHakyllConfiguration = HakyllConfiguration
21 , cacheDirectory = "_cache"
30 , cacheDirectory = "_cache"
22 }
31 }
23
32
24−-- | Hakyll with a default configuration.
33+-- | Main function to run Hakyll with the default configuration.
25hakyll :: Hakyll () -> IO ()
34hakyll :: Hakyll () -> IO ()
26hakyll = hakyllWithConfiguration defaultHakyllConfiguration
35hakyll = hakyllWithConfiguration defaultHakyllConfiguration
27
36
28−-- | Main function to run hakyll with a configuration.
37+-- | Main function to run hakyll with a custom configuration.
29hakyllWithConfiguration :: HakyllConfiguration -> Hakyll () -> IO ()
38hakyllWithConfiguration :: HakyllConfiguration -> Hakyll () -> IO ()
30hakyllWithConfiguration configuration buildFunction = do
39hakyllWithConfiguration configuration buildFunction = do
31 args <- getArgs
40 args <- getArgs
@@ -61,5 +70,6 @@ help = liftIO $ do
61 ++ name ++ " preview [port] Generate site, then start a server.\n"
70 ++ name ++ " preview [port] Generate site, then start a server.\n"
62 ++ name ++ " server [port] Run a local test server.\n"
71 ++ name ++ " server [port] Run a local test server.\n"
63
72
73+-- | Start a server at the given port number.
64server :: Integer -> Hakyll ()
74server :: Integer -> Hakyll ()
65server p = askHakyll siteDirectory >>= liftIO . simpleServer (fromIntegral p)
75server p = askHakyll siteDirectory >>= liftIO . simpleServer (fromIntegral p)
src/Text/Hakyll/File.hs+3−1
@@ -45,7 +45,9 @@ toCache :: FilePath -> Hakyll FilePath
45toCache path = do dir <- askHakyll cacheDirectory
45toCache path = do dir <- askHakyll cacheDirectory
46 return $ dir </> removeLeadingSeparator path
46 return $ dir </> removeLeadingSeparator path
47
47
48−-- | Get the url for a given page.
48+-- | Get the url for a given page. For most extensions, this would be the path
49+-- itself. It's only for rendered extensions (@.markdown@, @.rst@, @.lhs@ this
50+-- function returns a path with a @.html@ extension instead.
49toUrl :: FilePath -> FilePath
51toUrl :: FilePath -> FilePath
50toUrl path = if takeExtension path `elem` [ ".markdown"
52toUrl path = if takeExtension path `elem` [ ".markdown"
51 , ".md"
53 , ".md"