diff options
| author | Mirek Kratochvil <miroslav.kratochvil@uni.lu> | 2023-06-22 11:34:00 +0200 |
|---|---|---|
| committer | Mirek Kratochvil <miroslav.kratochvil@uni.lu> | 2023-06-22 11:43:28 +0200 |
| commit | fa7d1fab5550822b1f4cad753f122515a818a600 (patch) | |
| tree | 9931d559ffa3368263c00afbc76c40db6323e0ed /site.hs | |
| parent | 91900a323ca89592c200e55dc8afc65c8a9abe3a (diff) | |
| download | reploy-fa7d1fab5550822b1f4cad753f122515a818a600.tar.gz reploy-fa7d1fab5550822b1f4cad753f122515a818a600.tar.bz2 | |
avoid overwriting timestamps if they are forced by markdown already
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 |
