jekyll-svelte-slabs 0.0.10 → 0.1.0

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: 46209b41ae43688dc1283cb695ea7ca36481363867aa0832495e4cdad886e03e
4
- data.tar.gz: ce667eab704270985620ac6cb08d7005c6df825a680c3ed6686ced93902657c1
3
+ metadata.gz: f5ef8f206f07767eb491da6790c5057a582b37759b9fe912e2795c4f40631f9d
4
+ data.tar.gz: 9dc20d59547f2448458c007f51633697c90670b998e55e695c62b333de9ca82d
5
5
  SHA512:
6
- metadata.gz: 2abeb3045705a310a7cd9c3be12a938352e950ab81489441b7dfd927dbead751ce8eb7af4c58e43640049421020fbbfa8b29c844895c9a5be57d5ea681e8bb1f
7
- data.tar.gz: e88b546aba369c113104c0e4dfcf385525ce5da493aad0db64ff3fe4148233252ee7d8d6382cd69ef3d2f3804bf6690413da5787518ae3fbea5ca71b6bacc1f4
6
+ metadata.gz: cbbfa59cdbfc35cb82b493e54193604d22a7838ee2e1cd42fb64711087665f4315db2a99f5b1461f15aedd68d0c33f165faef9811b6c92105f22212da7628737
7
+ data.tar.gz: c8ad8265c6542955857be5b145757cdc0351e72c30257a3cdc310784c551b7e42b89e1b1ca785ae8494e071dda3d176a248e5dcc4ea5040323b99ada093fc9e2
@@ -1,3 +1,3 @@
1
1
  module JekyllSvelteSlabs
2
- VERSION = "0.0.10"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -1,6 +1,7 @@
1
1
  require "base64"
2
2
  require 'json'
3
3
  require 'digest'
4
+ require_relative "./output-data"
4
5
 
5
6
  module JekyllSvelteSlabs
6
7
 
@@ -130,31 +131,42 @@ module JekyllSvelteSlabs
130
131
 
131
132
  def render(context)
132
133
  text = super
133
- # puts Base64.encode64(context[@data].to_json)
134
+ site = context['site']
134
135
 
135
- # site = context.registers[:site]
136
- # puts site
137
-
138
- slab_config = context['site']['svelte_slabs'] || {}
136
+ slab_config = site['svelte_slabs'] || {}
139
137
  method = slab_config['method'] || "window"
140
138
 
141
139
  file = render_variable(context) || @file
142
140
  validate_file_name(file)
143
141
 
144
142
  svelte_data = @params ? parse_params(context).to_json : "{}"
145
- svelte_data = "\"#{Base64.strict_encode64(svelte_data)}\"" if method == "window_b"
146
- svelte_data = "`#{svelte_data.gsub("<", "&rawlt;").gsub("`", "\`")}`" if method == "window_e"
143
+
144
+ svelte_data = case method
145
+ when 'window_b' then "\"#{Base64.strict_encode64(svelte_data)}\""
146
+ when 'window_e' then "`#{svelte_data.gsub("<", "&rawlt;").gsub("`", "\`")}`"
147
+ else svelte_data
148
+ end
149
+
147
150
  endpoint = Digest::MD5.hexdigest(svelte_data)
148
151
 
149
- <<~MSG
150
- <script>
151
- window.svelteSlabs = window.svelteSlabs || {};
152
- window.svelteSlabs["#{endpoint}"] = #{svelte_data};
153
- </script>
154
- <div data-svelte-slab="#{file}" data-svelte-slab-props="#{method}:#{endpoint}">
155
- #{text}
156
- </div>
157
- MSG
152
+ if method == 'endpoint'
153
+ JekyllSvelteSlabs::SiteData.output(context.registers[:site], svelte_data, endpoint);
154
+ <<~MSG
155
+ <div data-svelte-slab="#{file}" data-svelte-slab-props="#{method}:#{endpoint}">
156
+ #{text}
157
+ </div>
158
+ MSG
159
+ else
160
+ <<~MSG
161
+ <script>
162
+ window.svelteSlabs = window.svelteSlabs || {};
163
+ window.svelteSlabs["#{endpoint}"] = #{svelte_data};
164
+ </script>
165
+ <div data-svelte-slab="#{file}" data-svelte-slab-props="#{method}:#{endpoint}">
166
+ #{text}
167
+ </div>
168
+ MSG
169
+ end
158
170
  end
159
171
 
160
172
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-svelte-slabs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Liam Bigelow
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-19 00:00:00.000000000 Z
11
+ date: 2021-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll