aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMirek Kratochvil <miroslav.kratochvil@uni.lu>2023-10-16 13:15:07 +0200
committerMirek Kratochvil <miroslav.kratochvil@uni.lu>2023-10-16 13:15:07 +0200
commitfca3de03e3b575a9d1390fcc24897e41f5ec5141 (patch)
treeeaec92b5381fa70f8f712646644b91574d64a3e4
parentfee144a3eca7e35b998061032f87d1e053999c6d (diff)
downloadreploy-fca3de03e3b575a9d1390fcc24897e41f5ec5141.tar.gz
reploy-fca3de03e3b575a9d1390fcc24897e41f5ec5141.tar.bz2
properly add the extra metadata to all pages, even tags
-rw-r--r--reploy.hs24
-rw-r--r--templates/list.html2
2 files changed, 13 insertions, 13 deletions
diff --git a/reploy.hs b/reploy.hs
index c29a81b..a244715 100644
--- a/reploy.hs
+++ b/reploy.hs
@@ -197,10 +197,11 @@ checkedSubstitute t v = do
-- | Add global information to page metadata for rendering (at this point just the url base)
addGlobalMeta :: Y.Value -> Site MT.Value
-addGlobalMeta (Y.Object m) = do
+addGlobalMeta meta = do
r <- use urlBase
rt <- rootedLink'
rtp <- rootedPageLink'
+ Y.Object m <- (`objMerge` meta) <$> use extraMeta
let l = map (\(k, v) -> (K.toText k, Mu.toMustache v)) $ KM.toList m
pure . Mu.object $ l ++
[ ("root", Mu.toMustache $ T.pack r)
@@ -219,17 +220,16 @@ addExtraMeta :: PageInfo -> Y.Value -> Site Y.Value
addExtraMeta pi m = do
metaPath <- metadataFile $ pi ^. pagePath
metaExists <- io $ doesFileExist metaPath
- gem <- use extraMeta
- objMerge gem <$>
- if metaExists
- then do
- em' <- io $ Y.decodeFileEither metaPath
- case em' of
- Left pe ->
- error $ "decoding " ++ metaPath ++ " failed: " ++
- Y.prettyPrintParseException pe
- Right em -> pure $ objMerge em m
- else pure m
+ if metaExists
+ then do
+ io $ putStrLn ("M <- " ++ metaPath)
+ em' <- io $ Y.decodeFileEither metaPath
+ case em' of
+ Left pe ->
+ error $ "decoding " ++ metaPath ++ " failed: " ++
+ Y.prettyPrintParseException pe
+ Right em -> pure $ objMerge em m
+ else pure m
-- | Add page-specific information to the metadata. In this instance, this just
-- expands the tags for rendering and continues by adding extra metadata via
diff --git a/templates/list.html b/templates/list.html
index 4c173f5..4c64888 100644
--- a/templates/list.html
+++ b/templates/list.html
@@ -15,7 +15,7 @@
{{?subtags}}<h3>Sub-categories</h3>
<ul>
{{#subtags}}
- <li>{{name}} (<a href="{{href}}">{{#htag}} » {{name}} {{/htag}}</a>)</li>
+ <li>{{name}} (<a href="{{href}}">{{#htag}} » {{name}}{{/htag}}</a>)</li>
{{/subtags}}
</ul>
{{/subtags}}