@@ -19,6 +19,7 @@
1919module Hakyll.Core.Rules
2020 ( Rules
2121 , match
22+ , matchMetadata
2223 , create
2324 , version
2425 , compile
@@ -120,16 +121,26 @@ flush = Rules $ do
120121
121122
122123--------------------------------------------------------------------------------
123−match :: Pattern -> Rules () -> Rules ()
124−match pattern rules = do
124+matchInternal :: Pattern -> Rules [Identifier] -> Rules () -> Rules ()
125+matchInternal pattern getIDs rules = do
125126 tellPattern pattern
126127 flush
127− ids <- getMatches pattern
128+ ids <- getIDs
128129 tellResources ids
129130 Rules $ local (setMatches ids) $ unRules $ rules >> flush
130131 where
131132 setMatches ids env = env {rulesMatches = ids}
132133
134+--------------------------------------------------------------------------------
135+match :: Pattern -> Rules () -> Rules ()
136+match pattern = matchInternal pattern $ getMatches pattern
137+
138+
139+--------------------------------------------------------------------------------
140+matchMetadata :: Pattern -> (Metadata -> Bool) -> Rules () -> Rules ()
141+matchMetadata pattern metadataPred = matchInternal pattern $
142+ map fst . filter (metadataPred . snd) <$> getAllMetadata pattern
143+
133144
134145--------------------------------------------------------------------------------
135146create :: [Identifier] -> Rules () -> Rules ()