diff options
Diffstat (limited to 'src/Hakyll/Web/Page')
-rw-r--r-- | src/Hakyll/Web/Page/Metadata.hs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/Hakyll/Web/Page/Metadata.hs b/src/Hakyll/Web/Page/Metadata.hs index 2880ece..23d98a4 100644 --- a/src/Hakyll/Web/Page/Metadata.hs +++ b/src/Hakyll/Web/Page/Metadata.hs @@ -2,6 +2,7 @@ -- module Hakyll.Web.Page.Metadata ( getField + , getFieldMaybe , setField , setFieldA , renderField @@ -31,7 +32,14 @@ import Hakyll.Web.Util.String getField :: String -- ^ Key -> Page a -- ^ Page -> String -- ^ Value -getField key = fromMaybe "" . M.lookup key . pageMetadata +getField key = fromMaybe "" . getFieldMaybe key + +-- | Get a field in a 'Maybe' wrapper +-- +getFieldMaybe :: String -- ^ Key + -> Page a -- ^ Page + -> Maybe String -- ^ Value, if found +getFieldMaybe key = M.lookup key . pageMetadata -- | Add a metadata field. If the field already exists, it is not overwritten. -- |