@@ -30,6 +30,8 @@ import qualified Hakyll.Core.Store as Store
32--------------------------------------------------------------------------------
32--------------------------------------------------------------------------------
33+-- | Whilst compiling an item, it possible to save multiple snapshots of it, and
34+-- not just the final result.
33type Snapshot = String
35type Snapshot = String
@@ -39,6 +41,8 @@ save store item = saveSnapshot store final item
41--------------------------------------------------------------------------------
43--------------------------------------------------------------------------------
44+-- | Save a specific snapshot of an item, so you can load it later using
42saveSnapshot :: (Binary a, Typeable a)
46saveSnapshot :: (Binary a, Typeable a)
43 => Store -> Snapshot -> Item a -> IO ()
47 => Store -> Snapshot -> Item a -> IO ()
44saveSnapshot store snapshot item =
48saveSnapshot store snapshot item =
@@ -46,11 +50,14 @@ saveSnapshot store snapshot item =
48--------------------------------------------------------------------------------
52--------------------------------------------------------------------------------
53+-- | Load an item compiled elsewhere. If the required item is not yet compiled,
54+-- the build system will take care of that automatically.
49require :: (Binary a, Typeable a) => Identifier -> Compiler (Item a)
55require :: (Binary a, Typeable a) => Identifier -> Compiler (Item a)
50require id' = requireSnapshot id' final
56require id' = requireSnapshot id' final
53--------------------------------------------------------------------------------
59--------------------------------------------------------------------------------
60+-- | Require a specific snapshot of an item.
54requireSnapshot :: (Binary a, Typeable a)
61requireSnapshot :: (Binary a, Typeable a)
55 => Identifier -> Snapshot -> Compiler (Item a)
62 => Identifier -> Snapshot -> Compiler (Item a)
56requireSnapshot id' snapshot = do
63requireSnapshot id' snapshot = do
@@ -77,6 +84,9 @@ requireSnapshot id' snapshot = do
79--------------------------------------------------------------------------------
86--------------------------------------------------------------------------------
87+-- | A shortcut for only requiring the body of an item.
89+-- > requireBody = fmap itemBody . require
80requireBody :: (Binary a, Typeable a) => Identifier -> Compiler a
90requireBody :: (Binary a, Typeable a) => Identifier -> Compiler a
81requireBody id' = requireSnapshotBody id' final
91requireBody id' = requireSnapshotBody id' final
@@ -88,6 +98,7 @@ requireSnapshotBody id' snapshot = fmap itemBody $ requireSnapshot id' snapshot
90--------------------------------------------------------------------------------
100--------------------------------------------------------------------------------
101+-- | This function allows you to 'require' a dynamic list of items
91requireAll :: (Binary a, Typeable a) => Pattern -> Compiler [Item a]
102requireAll :: (Binary a, Typeable a) => Pattern -> Compiler [Item a]
92requireAll pattern = requireAllSnapshots pattern final
103requireAll pattern = requireAllSnapshots pattern final
@@ -108,4 +119,4 @@ key identifier snapshot =
109--------------------------------------------------------------------------------
120--------------------------------------------------------------------------------
110final :: Snapshot
121final :: Snapshot
111−final = "final"
122+final = "_final"