summaryrefslogtreecommitdiff
path: root/src/Hakyll/Core/Rules.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Hakyll/Core/Rules.hs')
-rw-r--r--src/Hakyll/Core/Rules.hs17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/Hakyll/Core/Rules.hs b/src/Hakyll/Core/Rules.hs
index 1b1e4ae..14befde 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
@@ -120,16 +121,26 @@ flush = Rules $ do
--------------------------------------------------------------------------------
-match :: Pattern -> Rules () -> Rules ()
-match pattern rules = do
+matchInternal :: Pattern -> Rules [Identifier] -> Rules () -> Rules ()
+matchInternal pattern getIDs rules = do
tellPattern pattern
flush
- ids <- getMatches pattern
+ ids <- getIDs
tellResources ids
Rules $ local (setMatches ids) $ unRules $ rules >> flush
where
setMatches ids env = env {rulesMatches = ids}
+--------------------------------------------------------------------------------
+match :: Pattern -> Rules () -> Rules ()
+match pattern = matchInternal pattern $ getMatches pattern
+
+
+--------------------------------------------------------------------------------
+matchMetadata :: Pattern -> (Metadata -> Bool) -> Rules () -> Rules ()
+matchMetadata pattern metadataPred = matchInternal pattern $
+ map fst . filter (metadataPred . snd) <$> getAllMetadata pattern
+
--------------------------------------------------------------------------------
create :: [Identifier] -> Rules () -> Rules ()