File tree Expand file tree Collapse file tree 3 files changed +770
-12
lines changed Expand file tree Collapse file tree 3 files changed +770
-12
lines changed Original file line number Diff line number Diff line change 44
44
# out the following two lines has been known to help
45
45
activate :minify_css
46
46
activate :minify_javascript
47
+ activate :inline
47
48
# activate :relative_assets
48
49
# activate :asset_hash
49
50
# activate :gzip
55
56
56
57
helpers do
57
58
require './lib/toc_data.rb'
59
+ require './lib/middleman-inline.rb'
58
60
end
Original file line number Diff line number Diff line change
1
+ require "middleman-core"
2
+
3
+ # original code: https://github.com/miloshadzic/middleman-inline/blob/master/lib/middleman-inline/extension.rb
4
+ # I'm vendoring this because I couldn't get the gem working.
5
+ class MiddlemanInline < ::Middleman ::Extension
6
+ helpers do
7
+ def inline_css ( *args )
8
+ args . map do |arg |
9
+ "<style type='text/css'>#{ render_resource ( fname ( arg , '.css' ) ) } </style>"
10
+ end . join ( "\n " )
11
+ end
12
+
13
+ private
14
+
15
+ def fname ( str , ext )
16
+ str . concat ( ext ) unless str . match ( ext )
17
+ str
18
+ end
19
+
20
+ def render_resource ( fname )
21
+ x = sitemap . resources . find { |res | res . source_file . match ( fname ) }
22
+ x . render ( )
23
+ end
24
+ end
25
+ end
26
+
27
+ Middleman ::Extensions . register :inline do
28
+ MiddlemanInline
29
+ end
30
+
31
+
You can’t perform that action at this time.
0 commit comments