reintroduce unshown tag content

This commit is contained in:
Sarah Vaupel 2023-11-29 14:25:59 +01:00
parent b58dca1c9a
commit 7dd7434d4e

View File

@ -58,17 +58,17 @@ stripPathPrefix (splitDirectories -> prefix) =
handleIf :: Exception e => (e -> Bool) -> (e -> IO a) -> IO a -> IO a
handleIf predicate handler = handle $ \exc -> bool throwIO handler (predicate exc) exc
metadataShow :: [Item w] -> Compiler [Item w]
metadataShow = filterM $ \Item{itemIdentifier} -> maybe (True :: Bool) read <$> getMetadataField itemIdentifier "show"
metadataSort :: [Item w] -> Compiler [Item w]
metadataSort = sortOnM $ \Item{itemIdentifier} -> maybe (0 :: Integer) read <$> getMetadataField itemIdentifier "sort"
where
sortOnM :: forall m a b. (Monad m, Ord b) => (a -> m b) -> [a] -> m [a]
sortOnM f = fmap (map snd . List.sortOn fst) . mapM (\x -> (,x) <$> f x)
metadata :: [Item w] -> Compiler [Item w]
metadata = metadataShow >=> metadataSort
where
metadataShow :: [Item w] -> Compiler [Item w]
metadataShow = filterM $ \Item{itemIdentifier} -> maybe (True :: Bool) read <$> getMetadataField itemIdentifier "show"
metadataSort :: [Item w] -> Compiler [Item w]
metadataSort = sortOnM $ \Item{itemIdentifier} -> maybe (0 :: Integer) read <$> getMetadataField itemIdentifier "sort"
where
sortOnM :: forall m a b. (Monad m, Ord b) => (a -> m b) -> [a] -> m [a]
sortOnM f = fmap (map snd . List.sortOn fst) . mapM (\x -> (,x) <$> f x)
unwrapped :: Snapshot
unwrapped = "unwrapped"
@ -244,7 +244,7 @@ main =
let
ctx =
mconcat
[ listField "posts" postContext (metadata =<< loadAll posts)
[ listField "posts" postContext (metadataSort =<< loadAll posts)
, defaultContext
]