diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Hakyll/Web/Feed.hs | 4 | ||||
| -rw-r--r-- | src/Hakyll/Web/Template/Context.hs | 15 |
2 files changed, 15 insertions, 4 deletions
diff --git a/src/Hakyll/Web/Feed.hs b/src/Hakyll/Web/Feed.hs index c5f8e0b..1d18430 100644 --- a/src/Hakyll/Web/Feed.hs +++ b/src/Hakyll/Web/Feed.hs @@ -76,10 +76,10 @@ renderFeed feedPath itemPath config itemContext items = do loadTemplate = fmap readTemplate . readFile <=< getDataFileName itemContext' = mconcat - [ constField "root" (feedRoot config) + [ itemContext + , constField "root" (feedRoot config) , constField "authorName" (feedAuthorName config) , constField "authorEmail" (feedAuthorEmail config) - , itemContext ] feedContext = mconcat 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 |
