@@ -3,26 +3,30 @@ module Text.Hakyll.Hakyll
33 ( HakyllConfiguration (..)
44 , Hakyll
55 , askHakyll
6+ , getAdditionalContext
67 ) where
78
89import Control.Monad.Reader (ReaderT, ask)
910import Control.Monad (liftM)
11+import qualified Data.Map as M
1012
1113import Text.Hakyll.Context (Context)
1214
1315-- | Hakyll global configuration type.
1416data HakyllConfiguration = HakyllConfiguration
15− { -- | An additional context to use when rendering. This additional context
17+ { -- | Absolute URL of the site.
18+ absoluteUrl :: String
19+ , -- | An additional context to use when rendering. This additional context
1620 -- is used globally.
1721 additionalContext :: Context
1822 , -- | Directory where the site is placed.
19− siteDirectory :: FilePath
23+ siteDirectory :: FilePath
2024 , -- | Directory for cache files.
21− cacheDirectory :: FilePath
25+ cacheDirectory :: FilePath
2226 , -- | Enable index links.
23− enableIndexUrl :: Bool
27+ enableIndexUrl :: Bool
2428 , -- | Delay between polls in preview mode.
25− previewPollDelay :: Int
29+ previewPollDelay :: Int
2630 }
2731
2832-- | Our custom monad stack.
@@ -39,3 +43,8 @@ type Hakyll = ReaderT HakyllConfiguration IO
3943--
4044askHakyll :: (HakyllConfiguration -> a) -> Hakyll a
4145askHakyll = flip liftM ask
46+
47+getAdditionalContext :: HakyllConfiguration -> Context
48+getAdditionalContext configuration =
49+ M.insert "absolute" (absoluteUrl configuration)
50+ (additionalContext configuration)