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.
- checksums.yaml +4 -4
- data/lib/hyde-page-js.rb +16 -11
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 638071688d5ecd309d300544d9d203a5f64609bda6203381ee0a45ef1d8a0ae2
|
4
|
+
data.tar.gz: 91fd23bd129212c6c6257033b66d5e3ce2cefdd440f6a92a7faf1657e4b356fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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.
|
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
|
-
|
82
|
+
break if data == ""
|
78
83
|
|
79
84
|
data = minify(data)
|
80
|
-
|
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
|
-
#
|
91
|
-
@site.static_files
|
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
|
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.
|
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:
|
11
|
+
date: 2024-01-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|