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)
10
10
end
11
11
12
12
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
17
14
end
18
15
19
16
def fetch_route ( route )
20
- css_for_route route
21
- end
22
-
23
- protected
24
-
25
- def css_for_route ( route , css_path )
26
17
options = {
27
18
'url' => @config . base_url + route ,
28
- 'css' => css_path ,
29
- ## optional params
30
- # viewport dimensions
19
+ 'css' => fetch_css_path_for_route ( route ) , #implement
31
20
'width' => 1300 ,
32
21
'height' => 900 ,
22
+ 'timeout' => 30_000 ,
33
23
# CSS selectors to always include, e.g.:
34
24
'forceInclude' => [
35
25
# '.keepMeEvenIfNotSeenInDom',
36
26
# '^\.regexWorksToo'
37
27
] ,
38
- # ms; abort critical CSS generation after this timeout
39
- 'timeout' => 30_000 ,
40
28
# set to true to throw on CSS errors (will run faster if no errors)
41
29
'strict' => false ,
42
30
# characters; strip out inline base64 encoded resources larger than this
@@ -63,5 +51,17 @@ def css_for_route(route, css_path)
63
51
end
64
52
out
65
53
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
66
66
end
67
67
end
You can’t perform that action at this time.
0 commit comments