on master help sign in
Fix routes for specific list/group combo
52170d8Jasper Van der Jeugt
src/Hakyll/Core/Rules.hs+11−8
@@ -82,12 +82,21 @@ tellResources resources' = Rules $ tell $
82
82
83--------------------------------------------------------------------------------
83--------------------------------------------------------------------------------
84match :: Pattern -> Rules b -> Rules b
84match :: Pattern -> Rules b -> Rules b
85−match pattern = Rules . local addPattern . unRules
85+match pattern = Rules . censor matchRoutes . local addPattern . unRules
86 where
86 where
87 addPattern env = env
87 addPattern env = env
88 { rulesPattern = rulesPattern env `mappend` pattern
88 { rulesPattern = rulesPattern env `mappend` pattern
89 }
89 }
90
90
91+ -- Create a fast pattern for routing that matches exactly the compilers
92+ -- created in the block given to match
93+ matchRoutes ruleSet = ruleSet
94+ { rulesRoutes = matchRoute fastPattern (rulesRoutes ruleSet)
95+ }
96+ where
97+ fastPattern = fromList [id' | (id', _) <- rulesCompilers ruleSet]
98+
99+
91
100
92--------------------------------------------------------------------------------
101--------------------------------------------------------------------------------
93version :: String -> Rules a -> Rules a
102version :: String -> Rules a -> Rules a
@@ -122,13 +131,7 @@ compile compiler = do
122--
131--
123-- This adds a route for all items matching the current pattern.
132-- This adds a route for all items matching the current pattern.
124route :: Routes -> Rules ()
133route :: Routes -> Rules ()
125−route route' = Rules $ do
126− -- We want the route only to be applied if we match the current pattern and
127− -- version
128− pattern <- rulesPattern <$> ask
129− version' <- rulesVersion <$> ask
130− unRules $ tellRoute $ matchRoute
134+route = tellRoute
131− (pattern `mappend` fromVersion version') route'
132
135
133
136
134--------------------------------------------------------------------------------
137--------------------------------------------------------------------------------