diff options
| author | Mirek Kratochvil <exa.exa@gmail.com> | 2025-01-29 20:39:57 +0100 |
|---|---|---|
| committer | Mirek Kratochvil <exa.exa@gmail.com> | 2025-01-29 20:39:57 +0100 |
| commit | eeb49be54a981b3a92cd518a984c59f547ac14d6 (patch) | |
| tree | 40c8be9e1e8019268c2f264ea8051c47892933d9 /reploy.hs | |
| parent | 7596161a26f9738d22f5e6ea70bc4ea872ee9652 (diff) | |
| parent | f0258edf003fd58fe6df6b858bbccbc0efd70e08 (diff) | |
| download | reploy-eeb49be54a981b3a92cd518a984c59f547ac14d6.tar.gz reploy-eeb49be54a981b3a92cd518a984c59f547ac14d6.tar.bz2 | |
Merge changes from the old gitlab
Diffstat (limited to 'reploy.hs')
| -rw-r--r-- | reploy.hs | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -26,6 +26,7 @@ import qualified Data.Aeson as AE import qualified Data.Aeson.Key as K import qualified Data.Aeson.KeyMap as KM import qualified Data.ByteString.Lazy as B +import qualified Data.ByteString.UTF8 import Data.Digest.Pure.SHA (sha256, showDigest) import Data.Foldable (traverse_) import Data.List (inits, nub, sort) @@ -511,10 +512,37 @@ renderSearchData = use searchDataOut >>= traverse_ go putStrLn $ "S -> " ++ out AE.encodeFile out $ Y.array (concat ps) +-- | Souce extra metadata accordingly to the metadata specifications +sourceExtraMetadata :: Site () +sourceExtraMetadata = do + use extraMetaSpec + >>= fmap (foldl objMerge Y.Null) . traverse loadSpec + >>= assign extraMeta + where + loadSpec :: MetaSpec -> Site Y.Value + loadSpec (MetaSpecInline yaml) = + case Y.decodeEither' $ Data.ByteString.UTF8.fromString yaml of + Right v -> pure v + Left err -> + error + $ "cannot parse extra metadata from inline YAML: " + ++ Y.prettyPrintParseException err + loadSpec (MetaSpecFile path) = do + res <- io $ Y.decodeFileEither path + case res of + Right v -> pure v + Left err -> + error + $ "cannot load YAML metadata from " + ++ path + ++ ": " + ++ Y.prettyPrintParseException err + -- | Build the whole site. main = do init <- Options.Applicative.execParser siteOptions flip runStateT init $ do + sourceExtraMetadata installAssets use sourceDirs >>= traverse sourcePages use sourceDirs >>= traverse sourceTagMeta |
