diff options
| author | Mirek Kratochvil <exa.exa@gmail.com> | 2023-06-14 20:54:01 +0200 |
|---|---|---|
| committer | Mirek Kratochvil <exa.exa@gmail.com> | 2023-06-14 20:54:01 +0200 |
| commit | 8cb15d3960b8942deb96e1d143e5b6ede60d0a2d (patch) | |
| tree | 230b8ff544036330900672b4039a5dd5e84b8eaa | |
| parent | 0ab1096409bccc89ae76eb64c4f56cf0c9c9c8dd (diff) | |
| download | reploy-8cb15d3960b8942deb96e1d143e5b6ede60d0a2d.tar.gz reploy-8cb15d3960b8942deb96e1d143e5b6ede60d0a2d.tar.bz2 | |
global metadata
| -rw-r--r-- | site.hs | 15 | ||||
| -rw-r--r-- | templates/head.html | 4 |
2 files changed, 13 insertions, 6 deletions
@@ -151,6 +151,12 @@ checkedSubstitute t v = do --null es `unless` error "template substitution problems" pure txt +-- | Add global information to page metadata for rendering (at this point just the url base) +addGlobalMeta :: Y.Value -> Site Y.Value +addGlobalMeta (Y.Object m) = do + r <- fromString <$> use urlBase + pure . Y.Object $ KM.insert "root" r m + -- | Render a page using the current template. installPage :: FilePath -> PageInfo -> Site () installPage mount pi = do @@ -160,12 +166,13 @@ installPage mount pi = do fixedUrlDoc <- walkURLs (processLink $ pi ^. pagePath . to takeDirectory) $ pi ^. pageDoc checkTarget file + body <- io . runIOorExplode $ writeHtml5String htmlWriteOpts fixedUrlDoc + let Y.Object meta' = pi ^. pageMeta + meta = Y.Object $ KM.insert "body" (Y.String body) meta' + meta <- addGlobalMeta meta io $ do putStrLn $ "P -> " ++ file makeDirectories file - body <- runIOorExplode $ writeHtml5String htmlWriteOpts fixedUrlDoc - let Y.Object meta' = pi ^. pageMeta - meta = Y.Object $ KM.insert "body" (Y.String body) meta' checkedSubstitute templ meta >>= TIO.writeFile file installPageRedirects mount pi @@ -301,7 +308,7 @@ makeTagMeta tag = do htagMeta <- makeHTagMeta tag subtagsMeta <- Y.array <$> traverse makeHTagLinkMeta subtags pagesMeta <- Y.array <$> traverse makePageLinkMeta taggedPages - pure $ + addGlobalMeta $ Y.object [("htag", htagMeta), ("subtags", subtagsMeta), ("pages", pagesMeta)] diff --git a/templates/head.html b/templates/head.html index 7244cbe..bd85177 100644 --- a/templates/head.html +++ b/templates/head.html @@ -7,6 +7,6 @@ All cards {{#htag}} ยป {{tag}}{{/htag}} {{/htag}} </title> - <link rel="stylesheet" href="{{root}}/style.css" /> - <link rel="stylesheet" href="{{root}}/fonts.css" /> + <link rel="stylesheet" href="{{root}}style.css" /> + <link rel="stylesheet" href="{{root}}fonts.css" /> </head> |
