File tree Expand file tree Collapse file tree 1 file changed +15
-15
lines changed Expand file tree Collapse file tree 1 file changed +15
-15
lines changed Original file line number Diff line number Diff line change @@ -10,33 +10,21 @@ def initialize(config)
1010 end
1111
1212 def fetch
13- @config . routes . map . with_index { |route , index |
14- css_path = @config . css_paths [ index ] . present? ? @config . css_paths [ index ] : @config . css_path
15- [ route , css_for_route ( route , css_path ) ]
16- } . to_h
13+ @config . routes . map { |route | [ route , fetch_route ( route ) ] } . to_h
1714 end
1815
1916 def fetch_route ( route )
20- css_for_route route
21- end
22-
23- protected
24-
25- def css_for_route ( route , css_path )
2617 options = {
2718 'url' => @config . base_url + route ,
28- 'css' => css_path ,
29- ## optional params
30- # viewport dimensions
19+ 'css' => fetch_css_path_for_route ( route ) , #implement
3120 'width' => 1300 ,
3221 'height' => 900 ,
22+ 'timeout' => 30_000 ,
3323 # CSS selectors to always include, e.g.:
3424 'forceInclude' => [
3525 # '.keepMeEvenIfNotSeenInDom',
3626 # '^\.regexWorksToo'
3727 ] ,
38- # ms; abort critical CSS generation after this timeout
39- 'timeout' => 30_000 ,
4028 # set to true to throw on CSS errors (will run faster if no errors)
4129 'strict' => false ,
4230 # characters; strip out inline base64 encoded resources larger than this
@@ -63,5 +51,17 @@ def css_for_route(route, css_path)
6351 end
6452 out
6553 end
54+
55+ private
56+
57+ def fetch_css_path_for_route ( route )
58+ index_for_route = @config . routes . index ( route )
59+
60+ if index_for_route && @config . css_paths [ index_for_route ]
61+ @config . css_paths [ index_for_route ]
62+ else
63+ @config . css_path
64+ end
65+ end
6666 end
6767end
You can’t perform that action at this time.
0 commit comments