diff options
Diffstat (limited to 'src/Hakyll/Core')
-rw-r--r-- | src/Hakyll/Core/Rules.hs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/Hakyll/Core/Rules.hs b/src/Hakyll/Core/Rules.hs index c248a9b..1c8b93c 100644 --- a/src/Hakyll/Core/Rules.hs +++ b/src/Hakyll/Core/Rules.hs @@ -19,6 +19,7 @@ module Hakyll.Core.Rules ( Rules , match + , matchMetadata , create , version , compile @@ -132,6 +133,19 @@ match pattern rules = do -------------------------------------------------------------------------------- +matchMetadata :: Pattern -> (Metadata -> Bool) -> Rules () -> Rules () +matchMetadata pattern metadataPred rules = do + tellPattern pattern + flush + idsAndMetadata <- getAllMetadata pattern + let ids = map fst . filter (metadataPred . snd) $ idsAndMetadata + tellResources ids + Rules $ local (setMatches ids) $ unRules $ rules >> flush + where + setMatches ids env = env {rulesMatches = ids} + + +-------------------------------------------------------------------------------- create :: [Identifier] -> Rules () -> Rules () create ids rules = do flush |