jekyll-react-component 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/Gemfile.lock +6 -6
- data/lib/jekyll-react-component/version.rb +1 -1
- data/lib/jekyll-react-component.rb +29 -18
- 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: 30257ded0f3d4b67e399cd23f0c8b7e06a87ee1431a52406282a81059be60851
|
4
|
+
data.tar.gz: 890a4274afc9f3c6f4fd32f7d72ae384a622a31e8d397907d60ea6217f401f01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4598f2a84bf424cd52d21a7f7cd1dd10463ba96ad35a96aacd9a82dbc9d3159ff978d2ea8324a5ac41944841456d6b8f3fc60bc1f9fd83dd648ee9502f007c1
|
7
|
+
data.tar.gz: 787a01b9ab49259a35d8c3897a345197727699a568ef81b6f05422c892a925debf71a66c314ca649df7c6be005e5f0a09c64b68c620c3e08f3eaa541d0ed0ddc
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
jekyll-react-component (0.1.
|
4
|
+
jekyll-react-component (0.1.1)
|
5
5
|
activesupport (~> 6.1, >= 6.1.4.1)
|
6
6
|
jekyll
|
7
7
|
json-schema (~> 2.8, >= 2.8.1)
|
@@ -21,9 +21,9 @@ GEM
|
|
21
21
|
ast (2.4.2)
|
22
22
|
colorator (1.1.0)
|
23
23
|
concurrent-ruby (1.1.9)
|
24
|
-
ffi (1.15.
|
24
|
+
ffi (1.15.4)
|
25
25
|
forwardable-extended (2.6.0)
|
26
|
-
i18n (1.8.
|
26
|
+
i18n (1.8.11)
|
27
27
|
concurrent-ruby (~> 1.0)
|
28
28
|
jekyll (3.6.3)
|
29
29
|
addressable (~> 2.4)
|
@@ -49,7 +49,7 @@ GEM
|
|
49
49
|
rb-inotify (~> 0.9, >= 0.9.10)
|
50
50
|
mercenary (0.3.6)
|
51
51
|
minitest (5.14.4)
|
52
|
-
nokogiri (1.12.
|
52
|
+
nokogiri (1.12.5-x86_64-linux)
|
53
53
|
racc (~> 1.4)
|
54
54
|
parallel (1.20.1)
|
55
55
|
parser (3.0.2.0)
|
@@ -57,7 +57,7 @@ GEM
|
|
57
57
|
pathutil (0.16.2)
|
58
58
|
forwardable-extended (~> 2.6)
|
59
59
|
public_suffix (4.0.6)
|
60
|
-
racc (1.
|
60
|
+
racc (1.6.0)
|
61
61
|
rainbow (3.0.0)
|
62
62
|
rake (13.0.6)
|
63
63
|
rb-fsevent (0.11.0)
|
@@ -90,7 +90,7 @@ GEM
|
|
90
90
|
tzinfo (2.0.4)
|
91
91
|
concurrent-ruby (~> 1.0)
|
92
92
|
unicode-display_width (2.0.0)
|
93
|
-
zeitwerk (2.
|
93
|
+
zeitwerk (2.5.1)
|
94
94
|
|
95
95
|
PLATFORMS
|
96
96
|
x86_64-linux
|
@@ -5,25 +5,36 @@ require 'nokogiri'
|
|
5
5
|
require_relative 'jekyll-react-component/react_component'
|
6
6
|
require_relative 'jekyll-react-component/version'
|
7
7
|
|
8
|
+
$react_component_pages_id = []
|
9
|
+
|
10
|
+
Jekyll::Hooks.register [:pages, :posts], :pre_render do |page|
|
11
|
+
if page.content.match?(/\{% react_component .+ %\}(.|\n)*\{% endreact_component %\}/)
|
12
|
+
$react_component_pages_id << page.object_id
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
8
16
|
Jekyll::Hooks.register [:pages, :posts], :post_render do |page|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
head
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
"
|
19
|
-
|
20
|
-
|
21
|
-
|
17
|
+
if $react_component_pages_id.include?(page.object_id)
|
18
|
+
html = page.output
|
19
|
+
doc = Nokogiri::HTML(html)
|
20
|
+
head = doc.at_css('head')
|
21
|
+
unless head.nil?
|
22
|
+
head << <<~CODE
|
23
|
+
<script async src="https://unpkg.com/es-module-shims@0.12.8/dist/es-module-shims.js"></script>
|
24
|
+
<script type="importmap">
|
25
|
+
{
|
26
|
+
"imports": {
|
27
|
+
"react": "https://esm.sh/react",
|
28
|
+
"react-dom": "https://esm.sh/react-dom",
|
29
|
+
"htm": "https://esm.sh/htm",
|
30
|
+
"assets/": "/assets/"
|
31
|
+
}
|
22
32
|
}
|
23
|
-
|
24
|
-
|
25
|
-
|
33
|
+
</script>
|
34
|
+
CODE
|
35
|
+
end
|
36
|
+
|
37
|
+
$react_component_pages_id.clear
|
38
|
+
page.output = doc.to_html
|
26
39
|
end
|
27
|
-
|
28
|
-
page.output = doc.to_html
|
29
40
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-react-component
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Grzegorz Jakubiak
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|