hyde-page-js 0.3.2 → 0.3.4

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 +16 -11
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 71202952cbb7a6f848efb35f52b2567e0f5e71ff4c2bd03cb7900b646f76baf4
4
- data.tar.gz: 89a466f9500aab52b11934ba3a7d4983727b8932322bb26142dd36e18c981188
3
+ metadata.gz: 638071688d5ecd309d300544d9d203a5f64609bda6203381ee0a45ef1d8a0ae2
4
+ data.tar.gz: 91fd23bd129212c6c6257033b66d5e3ce2cefdd440f6a92a7faf1657e4b356fb
5
5
  SHA512:
6
- metadata.gz: 15e8b455e09fc47ed4c174588c2bd53b3fd38eb83a79fdc94515f7af6737292f3d7be05349e8010cb312243fb76d309e62bdcfe5905265b796c1571f278eaa01
7
- data.tar.gz: 3692c60d4d2a9b2511e19db565fc411281bf265465e1c5be0fd0c28d6a37ea2a64ccf61430ee455c47453b253307040cbec83687c2dbb2b80d0bc462bce11964
6
+ metadata.gz: 99f760e8c290c41b450fe49594369756c7412c69a024f8737e66a549813c9a1f7c59797bd318f2191b837e24af0e42d36d74b90d1f3edf210fb8f343e73f6132
7
+ data.tar.gz: 0633dcf9452d791ea464dc4094d7e45c8411dd06ca307bc2d1255bd38259bc7f200ea03777d7ce2957e416ef0510a8469ad1817e98a386ba92279f0066917240
data/lib/hyde-page-js.rb CHANGED
@@ -2,14 +2,18 @@ require 'terser'
2
2
  require 'digest'
3
3
  require 'jekyll'
4
4
 
5
- Jekyll::Hooks.register :pages, :post_init do |page, payload|
5
+ Jekyll::Hooks.register :pages, :post_init do |page|
6
6
  Hyde::Page::Js.new(page).run if page.instance_of? Jekyll::Page
7
7
  end
8
8
 
9
+ Jekyll::Hooks.register :documents, :pre_render do |document|
10
+ Hyde::Page::Js.new(document).run if document.instance_of? Jekyll::Document
11
+ end
12
+
9
13
  module Hyde
10
14
  module Page
11
15
  class Js
12
- VERSION = "0.3.2"
16
+ VERSION = "0.3.4"
13
17
  end
14
18
 
15
19
  class GeneratedJsFile < Jekyll::StaticFile
@@ -66,29 +70,30 @@ module Hyde
66
70
  js = fetch_js(@page)
67
71
  layout = fetch_layout(fetch_layout_name(@page))
68
72
  js_groups = parent_layout_js(layout, js).reverse
69
- return if js_groups.empty?
73
+ return if js_groups.flatten.empty?
70
74
 
71
75
  for group in js_groups
76
+ next if group.empty?
72
77
  lookup_name = names_to_key(group)
73
78
  cache_entry = @site.data['_hyde_pages_cache'].fetch(lookup_name, nil)
74
79
 
75
80
  if cache_entry.nil?
76
81
  data = concatenate_files(group)
77
- return if data == ""
82
+ break if data == ""
78
83
 
79
84
  data = minify(data)
80
- return if data == ""
85
+ break if data == ""
81
86
 
82
87
  generated_file = generate_file(group, data)
83
88
 
84
- # file already exists, so skip writing out the data to disk
85
- return unless @site.static_files.find { |static_file| static_file.name == generated_file.name }.nil?
86
-
87
89
  # place file data into the new file
88
90
  generated_file.file_contents = data
89
91
 
90
- # assign static file to list for jekyll to render
91
- @site.static_files << generated_file
92
+ # file doesn't exists, so skip writing out the data to disk
93
+ if @site.static_files.find { |static_file| static_file.name == generated_file.name }.nil?
94
+ # assign static file to list for jekyll to render
95
+ @site.static_files << generated_file
96
+ end
92
97
 
93
98
  # add to cache
94
99
  cache_entry = {
@@ -99,7 +104,7 @@ module Hyde
99
104
  end
100
105
 
101
106
  # assign to site.data.js_files for liquid output
102
- add_to_urls(cache_entry.fetch(:url, nil)).compact
107
+ add_to_urls(cache_entry&.fetch(:url, nil))
103
108
  end
104
109
  end
105
110
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hyde-page-js
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregory Daynes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-12-27 00:00:00.000000000 Z
11
+ date: 2024-01-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll