Draft: Make initial content publicly available #12

Open
savau wants to merge 54 commits from content into main
Showing only changes of commit b58dca1c9a - Show all commits

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
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)
metadataShow :: [Item w] -> Compiler [Item w]
metadataShow = filterM $ \Item{itemIdentifier} -> maybe (True :: Bool) read <$> getMetadataField itemIdentifier "show"
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 (metadataSort =<< loadAll posts)
[ listField "posts" postContext (metadata =<< loadAll posts)
, defaultContext
]