hyde-page-js 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/hyde-page-js.rb +15 -1
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 867063daf19d510599c6474020f8f133c2564628a1eeb72b02a4aeb23a33d4ed
4
- data.tar.gz: ba3b8d908e8e3af80e8d31757bc9a39d28e10fb2408de974ca0fd31978197fad
3
+ metadata.gz: 17a523c022d3eb4883130d9b143285e028f4f83fcfe3011f614ab0ec25a05aef
4
+ data.tar.gz: b9b674f5042f528004838ab8e73a6f8840e70ae0bdb675f7991de420d715ff6f
5
5
  SHA512:
6
- metadata.gz: e8b40488499185989b1155c71c37e18bbb418f9b5017e2dd8b55e0b96600148bb86eab059d6289aaf93ec1eaab0a91052606194c4314f71a0b03b779f8a9d421
7
- data.tar.gz: d716cd8a8d0fb70ec94e3dec9cf4cbf12e66e6fda60f4338967fe52f8834e3d75ae1fd10feb1dbe3e0d3f97c6bdc672bd8194e7e91eae7ebb6088da329288a58
6
+ metadata.gz: 2e5799de5113ea965a1d638bf7a69eba7946fc7133d5f5d8cf4d37a13090902d7b97a703f226c749c2c44f3bb78f578cc1a514c8e11d31ceecf2dabc08bd041f
7
+ data.tar.gz: 203b8c566d58cebc526c8627425d6638b722003a4022b3af4d91126f64eba90696d289e808d3913fd7212f5fdb9e4c285a20131b2b313cb5166e8d2b12b4b7a1
data/lib/hyde-page-js.rb CHANGED
@@ -9,7 +9,7 @@ end
9
9
  module Hyde
10
10
  module Page
11
11
  class Js
12
- VERSION = "0.2.0"
12
+ VERSION = "0.3.0"
13
13
  end
14
14
 
15
15
  class GeneratedJsFile < Jekyll::StaticFile
@@ -55,6 +55,7 @@ module Hyde
55
55
  @page = page
56
56
  @site = page.site
57
57
  @config = fetch_config
58
+ @site.data['_hyde_pages_cache'] ||= {}
58
59
 
59
60
  if keep_files? && !dev_mode?
60
61
  @site.config.fetch("keep_files").push(destination)
@@ -65,6 +66,10 @@ module Hyde
65
66
  js = fetch_js(@page)
66
67
  layout = fetch_layout(fetch_layout_name(@page))
67
68
  results = parent_layout_js(layout, js).reverse
69
+ return if results.empty?
70
+
71
+ lookup_name = names_to_key(results)
72
+ return unless @site.data['_hyde_pages_cache'].fetch(lookup_name, nil).nil?
68
73
 
69
74
  data = concatenate_files(results)
70
75
  return if data == ""
@@ -85,10 +90,17 @@ module Hyde
85
90
 
86
91
  # assign to site.data.js_files for liquid output
87
92
  add_to_urls(generated_file.url)
93
+
94
+ # add to cache
95
+ @site.data['_hyde_pages_cache'][lookup_name] = data
88
96
  end
89
97
 
90
98
  private
91
99
 
100
+ def names_to_key(names)
101
+ names.join('-')
102
+ end
103
+
92
104
  def add_to_urls(url)
93
105
  @site.data['js_files'] ||= []
94
106
  @site.data['js_files'].push(url)
@@ -172,6 +184,8 @@ module Hyde
172
184
  end
173
185
 
174
186
  def minify(data)
187
+ return data unless minify?
188
+
175
189
  converter_config = {mangle: mangle?, output: {comments: :copyright}}
176
190
  js_converter = Terser.new(converter_config)
177
191
  js_converter.compile(data)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hyde-page-js
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregory Daynes