diff options
Diffstat (limited to 'site.hs')
| -rw-r--r-- | site.hs | 20 |
1 files changed, 11 insertions, 9 deletions
@@ -182,15 +182,17 @@ timestampFile fp = do -- | If a timestamp file for the page exists, add the timestamp metadata. addTimeMeta :: PageInfo -> Y.Value -> Site Y.Value -addTimeMeta pi m'@(Y.Object m) = do - tspath <- timestampFile $ pi ^. pagePath - io $ - ifM - (doesFileExist tspath) - (do putStrLn $ "timestamp <- " ++ tspath - ts <- Y.String <$> TIO.readFile tspath - pure . Y.Object $ KM.insert "timestamp" ts m) - (pure m') +addTimeMeta pi m'@(Y.Object m) + | "timestamp" `KM.member` m = pure m' -- do not overwrite the timestamp if present + | otherwise = do + tspath <- timestampFile $ pi ^. pagePath + io $ + ifM + (doesFileExist tspath) + (do putStrLn $ "timestamp <- " ++ tspath + ts <- Y.String <$> TIO.readFile tspath + pure . Y.Object $ KM.insert "timestamp" ts m) + (pure m') -- | Add page-specific information to the metadata. In this instance, this just -- expands the tags for rendering. Eventually would be nice to have the timestamps |
