summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJasper Van der Jeugt <m@jaspervdj.be>2015-10-24 11:42:25 +0200
committerJasper Van der Jeugt <m@jaspervdj.be>2015-10-24 11:42:25 +0200
commit0bfa763dc6d541ccf21da9456643067b3d96872f (patch)
tree82df9edf746c2328e28d2b31bf1e681e816f313f
parent8dec0a51fbcab519755147828b546abdb397fbd8 (diff)
downloadhakyll-0bfa763dc6d541ccf21da9456643067b3d96872f.tar.gz
Export getModificationTime
-rw-r--r--hakyll.cabal2
-rw-r--r--src/Hakyll/Web/Template/Context.hs15
-rw-r--r--web/releases.markdown4
3 files changed, 18 insertions, 3 deletions
diff --git a/hakyll.cabal b/hakyll.cabal
index c0c5856..a4fa093 100644
--- a/hakyll.cabal
+++ b/hakyll.cabal
@@ -1,5 +1,5 @@
Name: hakyll
-Version: 4.7.3.1
+Version: 4.7.4.0
Synopsis: A static website compiler library
Description:
diff --git a/src/Hakyll/Web/Template/Context.hs b/src/Hakyll/Web/Template/Context.hs
index 43857ff..6879187 100644
--- a/src/Hakyll/Web/Template/Context.hs
+++ b/src/Hakyll/Web/Template/Context.hs
@@ -21,6 +21,7 @@ module Hakyll.Web.Template.Context
, dateField
, dateFieldWith
, getItemUTC
+ , getItemModificationTime
, modificationTimeField
, modificationTimeFieldWith
, teaserField
@@ -296,6 +297,17 @@ getItemUTC locale id' = do
--------------------------------------------------------------------------------
+-- | Get the time on which the actual file was last modified. This only works if
+-- there actually is an underlying file, of couse.
+getItemModificationTime
+ :: Identifier
+ -> Compiler UTCTime
+getItemModificationTime identifier = do
+ provider <- compilerProvider <$> compilerAsk
+ return $ resourceModificationTime provider identifier
+
+
+--------------------------------------------------------------------------------
modificationTimeField :: String -- ^ Key
-> String -- ^ Format
-> Context a -- ^ Resuting context
@@ -308,8 +320,7 @@ modificationTimeFieldWith :: TimeLocale -- ^ Time output locale
-> String -- ^ Format
-> Context a -- ^ Resulting context
modificationTimeFieldWith locale key fmt = field key $ \i -> do
- provider <- compilerProvider <$> compilerAsk
- let mtime = resourceModificationTime provider $ itemIdentifier i
+ mtime <- getItemModificationTime $ itemIdentifier i
return $ formatTime locale fmt mtime
diff --git a/web/releases.markdown b/web/releases.markdown
index 7783ffa..3e23afa 100644
--- a/web/releases.markdown
+++ b/web/releases.markdown
@@ -4,6 +4,10 @@ title: Releases
# Releases
+## Hakyll 4.7.4.0
+
+- Expose `getItemModificationTime`
+
## Hakyll 4.7.3.1
- Bump pandoc-citeproc dependency to 0.8