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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2e44c4e823fa84a4567f15e40288c8db710885bce4d95716f304caafd5e73e74
4
- data.tar.gz: 31270a1e3017e51d709cb750717282234bc31963de78282e02d266279ceb2441
3
+ metadata.gz: 30257ded0f3d4b67e399cd23f0c8b7e06a87ee1431a52406282a81059be60851
4
+ data.tar.gz: 890a4274afc9f3c6f4fd32f7d72ae384a622a31e8d397907d60ea6217f401f01
5
5
  SHA512:
6
- metadata.gz: 46b2cf9d2a5abf2244b9a042ecb5ae87652b22fd359176dd4561bc67ac77e81960d487b7bc45cf2c5458295aafff3931b1fa2359207f731828ec3e67f29b68c2
7
- data.tar.gz: 38ce024efa0becc89b14628ced1fe6d96274c2ed2235e1eac225417925dcf8b406cc308549dad127eaa8420731db781889cb3d3a3b820e76649352698dd14430
6
+ metadata.gz: f4598f2a84bf424cd52d21a7f7cd1dd10463ba96ad35a96aacd9a82dbc9d3159ff978d2ea8324a5ac41944841456d6b8f3fc60bc1f9fd83dd648ee9502f007c1
7
+ data.tar.gz: 787a01b9ab49259a35d8c3897a345197727699a568ef81b6f05422c892a925debf71a66c314ca649df7c6be005e5f0a09c64b68c620c3e08f3eaa541d0ed0ddc
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.1.1] - 2022-02-05
4
+ - Add import map only if a page defines react_component
5
+
3
6
  ## [0.1.0] - 2021-08-28
4
7
 
5
8
  - Initial release
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jekyll-react-component (0.1.0)
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.3)
24
+ ffi (1.15.4)
25
25
  forwardable-extended (2.6.0)
26
- i18n (1.8.10)
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.3-x86_64-linux)
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.5.2)
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.4.2)
93
+ zeitwerk (2.5.1)
94
94
 
95
95
  PLATFORMS
96
96
  x86_64-linux
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Jekyll
4
4
  module ReactComponent
5
- VERSION = '0.1.0'
5
+ VERSION = '0.1.1'
6
6
  end
7
7
  end
@@ -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
- html = page.output
10
- doc = Nokogiri::HTML(html)
11
- head = doc.at_css('head')
12
- unless head.nil?
13
- head << <<~CODE
14
- <script async src="https://unpkg.com/es-module-shims@0.12.8/dist/es-module-shims.js"></script>
15
- <script type="importmap">
16
- {
17
- "imports": {
18
- "react": "https://esm.sh/react",
19
- "react-dom": "https://esm.sh/react-dom",
20
- "htm": "https://esm.sh/htm",
21
- "assets/": "/assets/"
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
- </script>
25
- CODE
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.0
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: 2021-09-07 00:00:00.000000000 Z
11
+ date: 2022-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport