A little more documentation.
This commit is contained in:
parent
7afabf5c09
commit
fbd9ff95bd
2 changed files with 16 additions and 4 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
-- | This is the main Hakyll module, exporting the important @hakyl@ function.
|
||||||
|
--
|
||||||
|
-- Most configurations would use this @hakyll@ function more or less as the
|
||||||
|
-- main function:
|
||||||
|
--
|
||||||
|
-- > main = hakyll $ do
|
||||||
|
-- > directory css "css"
|
||||||
|
-- > directory static "images"
|
||||||
|
--
|
||||||
module Text.Hakyll
|
module Text.Hakyll
|
||||||
( defaultHakyllConfiguration
|
( defaultHakyllConfiguration
|
||||||
, hakyll
|
, hakyll
|
||||||
|
@ -13,7 +22,7 @@ import System.Directory (doesDirectoryExist, removeDirectoryRecursive)
|
||||||
import Network.Hakyll.SimpleServer (simpleServer)
|
import Network.Hakyll.SimpleServer (simpleServer)
|
||||||
import Text.Hakyll.Hakyll
|
import Text.Hakyll.Hakyll
|
||||||
|
|
||||||
-- | Default hakyll configuration.
|
-- | The default hakyll configuration.
|
||||||
defaultHakyllConfiguration :: HakyllConfiguration
|
defaultHakyllConfiguration :: HakyllConfiguration
|
||||||
defaultHakyllConfiguration = HakyllConfiguration
|
defaultHakyllConfiguration = HakyllConfiguration
|
||||||
{ additionalContext = M.empty
|
{ additionalContext = M.empty
|
||||||
|
@ -21,11 +30,11 @@ defaultHakyllConfiguration = HakyllConfiguration
|
||||||
, cacheDirectory = "_cache"
|
, cacheDirectory = "_cache"
|
||||||
}
|
}
|
||||||
|
|
||||||
-- | Hakyll with a default configuration.
|
-- | Main function to run Hakyll with the default configuration.
|
||||||
hakyll :: Hakyll () -> IO ()
|
hakyll :: Hakyll () -> IO ()
|
||||||
hakyll = hakyllWithConfiguration defaultHakyllConfiguration
|
hakyll = hakyllWithConfiguration defaultHakyllConfiguration
|
||||||
|
|
||||||
-- | Main function to run hakyll with a configuration.
|
-- | Main function to run hakyll with a custom configuration.
|
||||||
hakyllWithConfiguration :: HakyllConfiguration -> Hakyll () -> IO ()
|
hakyllWithConfiguration :: HakyllConfiguration -> Hakyll () -> IO ()
|
||||||
hakyllWithConfiguration configuration buildFunction = do
|
hakyllWithConfiguration configuration buildFunction = do
|
||||||
args <- getArgs
|
args <- getArgs
|
||||||
|
@ -61,5 +70,6 @@ help = liftIO $ do
|
||||||
++ name ++ " preview [port] Generate site, then start a server.\n"
|
++ name ++ " preview [port] Generate site, then start a server.\n"
|
||||||
++ name ++ " server [port] Run a local test server.\n"
|
++ name ++ " server [port] Run a local test server.\n"
|
||||||
|
|
||||||
|
-- | Start a server at the given port number.
|
||||||
server :: Integer -> Hakyll ()
|
server :: Integer -> Hakyll ()
|
||||||
server p = askHakyll siteDirectory >>= liftIO . simpleServer (fromIntegral p)
|
server p = askHakyll siteDirectory >>= liftIO . simpleServer (fromIntegral p)
|
||||||
|
|
|
@ -45,7 +45,9 @@ toCache :: FilePath -> Hakyll FilePath
|
||||||
toCache path = do dir <- askHakyll cacheDirectory
|
toCache path = do dir <- askHakyll cacheDirectory
|
||||||
return $ dir </> removeLeadingSeparator path
|
return $ dir </> removeLeadingSeparator path
|
||||||
|
|
||||||
-- | Get the url for a given page.
|
-- | Get the url for a given page. For most extensions, this would be the path
|
||||||
|
-- itself. It's only for rendered extensions (@.markdown@, @.rst@, @.lhs@ this
|
||||||
|
-- function returns a path with a @.html@ extension instead.
|
||||||
toUrl :: FilePath -> FilePath
|
toUrl :: FilePath -> FilePath
|
||||||
toUrl path = if takeExtension path `elem` [ ".markdown"
|
toUrl path = if takeExtension path `elem` [ ".markdown"
|
||||||
, ".md"
|
, ".md"
|
||||||
|
|
Loading…
Reference in a new issue