add metadata to hide tags from menu

This commit is contained in:
Sarah Vaupel 2023-11-29 13:24:24 +01:00
parent ce37f7c14b
commit 430a4c78d1
2 changed files with 10 additions and 2 deletions

View File

@ -45,6 +45,7 @@ config :: Configuration
config =
defaultConfiguration
{ destinationDirectory = "public"
, previewPort = 8008
}
routeAsFilePath :: (FilePath -> FilePath) -> Routes
@ -63,6 +64,12 @@ metadataSort = sortOnM $ \Item{itemIdentifier} -> maybe (0 :: Integer) read <$>
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 = metadataSort <=< metadataShow
unwrapped :: Snapshot
unwrapped = "unwrapped"
@ -171,8 +178,8 @@ main =
where
ctx' =
mconcat
[ listField "tags-nav" defaultContext (metadataSort <=< mapM (uncurry renderTagNav) $ tagsMap tags)
, listField "special-nav" defaultContext $ metadataSort =<< mapM (flip loadSnapshot unwrapped) =<< getMatches (fromGlob "special/**")
[ listField "tags-nav" defaultContext (metadata <=< mapM (uncurry renderTagNav) $ tagsMap tags)
, listField "special-nav" defaultContext $ metadata =<< mapM (flip loadSnapshot unwrapped) =<< getMatches (fromGlob "special/**")
, frontendContext
, defaultContext
]

View File

@ -1,4 +1,5 @@
---
title: Index
sort: -9999
show: "False"
---