avoid overwriting timestamps if they are forced by markdown already
This commit is contained in:
parent
91900a323c
commit
fa7d1fab55
3
Types.hs
3
Types.hs
|
@ -132,7 +132,8 @@ siteOptions' = do
|
||||||
_timestampSuffix <-
|
_timestampSuffix <-
|
||||||
strOption $
|
strOption $
|
||||||
long "timestamp-prefix" <>
|
long "timestamp-prefix" <>
|
||||||
help "Timestamp file suffix for markdowns" <> value ".timestamp" <> showDefault
|
help "Timestamp file suffix for markdowns" <>
|
||||||
|
value ".timestamp" <> showDefault
|
||||||
_dumpFinalState <-
|
_dumpFinalState <-
|
||||||
switch $
|
switch $
|
||||||
long "dump-state" <>
|
long "dump-state" <>
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
mount: /404
|
mount: /404
|
||||||
title: Page not found
|
title: Page not found
|
||||||
search: off
|
search: off
|
||||||
|
toc: off
|
||||||
|
timestamp: null
|
||||||
---
|
---
|
||||||
|
|
||||||
# Page not found!
|
# Page not found!
|
||||||
|
|
|
@ -3,6 +3,7 @@ mount: /
|
||||||
title: Home
|
title: Home
|
||||||
template: index.html
|
template: index.html
|
||||||
toc: off
|
toc: off
|
||||||
|
timestamp: null
|
||||||
---
|
---
|
||||||
|
|
||||||
#### What are How-To Cards?
|
#### What are How-To Cards?
|
||||||
|
|
|
@ -4,6 +4,7 @@ title: Search
|
||||||
template: search.html
|
template: search.html
|
||||||
search: off
|
search: off
|
||||||
toc: off
|
toc: off
|
||||||
|
timestamp: null
|
||||||
---
|
---
|
||||||
|
|
||||||
# Search
|
# Search
|
||||||
|
|
20
site.hs
20
site.hs
|
@ -182,15 +182,17 @@ timestampFile fp = do
|
||||||
|
|
||||||
-- | If a timestamp file for the page exists, add the timestamp metadata.
|
-- | If a timestamp file for the page exists, add the timestamp metadata.
|
||||||
addTimeMeta :: PageInfo -> Y.Value -> Site Y.Value
|
addTimeMeta :: PageInfo -> Y.Value -> Site Y.Value
|
||||||
addTimeMeta pi m'@(Y.Object m) = do
|
addTimeMeta pi m'@(Y.Object m)
|
||||||
tspath <- timestampFile $ pi ^. pagePath
|
| "timestamp" `KM.member` m = pure m' -- do not overwrite the timestamp if present
|
||||||
io $
|
| otherwise = do
|
||||||
ifM
|
tspath <- timestampFile $ pi ^. pagePath
|
||||||
(doesFileExist tspath)
|
io $
|
||||||
(do putStrLn $ "timestamp <- " ++ tspath
|
ifM
|
||||||
ts <- Y.String <$> TIO.readFile tspath
|
(doesFileExist tspath)
|
||||||
pure . Y.Object $ KM.insert "timestamp" ts m)
|
(do putStrLn $ "timestamp <- " ++ tspath
|
||||||
(pure m')
|
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
|
-- | 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
|
-- expands the tags for rendering. Eventually would be nice to have the timestamps
|
||||||
|
|
Loading…
Reference in a new issue