diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Hakyll/Core/Compiler.hs | 1 | ||||
| -rw-r--r-- | src/Hakyll/Web/Page/Metadata.hs | 25 |
2 files changed, 26 insertions, 0 deletions
diff --git a/src/Hakyll/Core/Compiler.hs b/src/Hakyll/Core/Compiler.hs index d63c420..409cff0 100644 --- a/src/Hakyll/Core/Compiler.hs +++ b/src/Hakyll/Core/Compiler.hs @@ -98,6 +98,7 @@ module Hakyll.Core.Compiler , getRouteFor , getResourceString , getResourceLBS + , getResourceWith , fromDependency , require_ , require diff --git a/src/Hakyll/Web/Page/Metadata.hs b/src/Hakyll/Web/Page/Metadata.hs index 89e17b6..efae390 100644 --- a/src/Hakyll/Web/Page/Metadata.hs +++ b/src/Hakyll/Web/Page/Metadata.hs @@ -12,6 +12,8 @@ module Hakyll.Web.Page.Metadata , copyField , renderDateField , renderDateFieldWith + , renderModificationTime + , renderModificationTimeWith , copyBodyToField , copyBodyFromField ) where @@ -31,6 +33,7 @@ import Hakyll.Web.Page.Internal import Hakyll.Core.Util.String import Hakyll.Core.Identifier import Hakyll.Core.Compiler +import Hakyll.Core.Resource.Provider -- | Get a metadata field. If the field does not exist, the empty string is -- returned. @@ -151,6 +154,28 @@ renderDateFieldWith locale key format defaultValue = dateString :: Maybe UTCTime return $ formatTime locale format time +-- | Set the modification time as a field in the page +-- +renderModificationTime :: String + -- ^ Destination key + -> String + -- ^ Format to use on the time + -> Compiler (Page String) (Page String) + -- ^ Resulting compiler +renderModificationTime = renderModificationTimeWith defaultTimeLocale + +renderModificationTimeWith :: TimeLocale + -- ^ Output time locale + -> String + -- ^ Destination key + -> String + -- ^ Format to use on the time + -> Compiler (Page String) (Page String) + -- ^ Resulting compiler +renderModificationTimeWith locale key format = + id &&& (getResource >>> getResourceWith resourceModificationTime) >>> + setFieldA key (arr (formatTime locale format)) + -- | Copy the body of a page to a metadata field -- copyBodyToField :: String -- ^ Destination key |
