jekyll-bookshop 1.4.4 → 2.0.0.pre.alpha.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jekyll-bookshop.rb +75 -12
- data/lib/jekyll-bookshop/version.rb +1 -1
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5dcfebd607dda67280a95931eadee542b2a0018df3f5562b3439ec3f3ab2c4c4
|
4
|
+
data.tar.gz: 3614e23aa9fdf1d9fa31157e0612157f55d30c716ed46b1c40fbe001f7c521fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b7b413b32a1f126733a8f37a0860e4321b5933fb8844775aad40e7d840fbf8f2c4a85cb06169e972ae95c5e9ca039c6549587ac5c29f703bed7add368550752
|
7
|
+
data.tar.gz: '01970a6a13c8571afeec9a9075250a5fed66eaee7229226ef56431cddaad0d50b1953ec0e6a7683cdfb05d66d84bdd99276e6bc8b22fdd95daa4a05c2ec652c8'
|
data/lib/jekyll-bookshop.rb
CHANGED
@@ -3,18 +3,16 @@ require 'pathname'
|
|
3
3
|
|
4
4
|
module JekyllBookshop
|
5
5
|
class Tag < Jekyll::Tags::IncludeTag
|
6
|
-
def initialize(tag_name, markup, tokens)
|
7
|
-
cpath = markup.strip.partition(" ").first
|
8
|
-
cname = cpath.strip.split("/").last
|
9
|
-
tag = markup.strip.partition(" ").last
|
10
|
-
markup = "#{cpath}/#{cname}.jekyll.html #{tag}"
|
11
|
-
super
|
12
|
-
end
|
13
6
|
|
7
|
+
# Look for includes in the built bookshop directory
|
14
8
|
def tag_includes_dirs(context)
|
15
|
-
|
9
|
+
bookshop_locations = context['site']['bookshop_locations']&.collect do |location|
|
10
|
+
Pathname.new(location + "/components").cleanpath.to_s
|
11
|
+
end
|
12
|
+
bookshop_locations.freeze
|
16
13
|
end
|
17
14
|
|
15
|
+
# Support the bind syntax, spreading an object into params
|
18
16
|
def parse_params(context)
|
19
17
|
params = super
|
20
18
|
|
@@ -26,17 +24,81 @@ module JekyllBookshop
|
|
26
24
|
end
|
27
25
|
end
|
28
26
|
|
27
|
+
params.delete('bind')
|
28
|
+
|
29
29
|
params
|
30
30
|
end
|
31
|
+
|
32
|
+
# Map component names to the .jekyll.html files found in bookshop
|
33
|
+
def render(context)
|
34
|
+
site = context.registers[:site]
|
35
|
+
|
36
|
+
file = render_variable(context) || @file
|
37
|
+
cname = file.strip.split("/").last
|
38
|
+
file = "#{file}/#{cname}.jekyll.html"
|
39
|
+
validate_file_name(file)
|
40
|
+
|
41
|
+
path = locate_include_file(context, file, site.safe)
|
42
|
+
return unless path
|
43
|
+
|
44
|
+
add_include_to_dependency(site, path, context)
|
45
|
+
|
46
|
+
partial = load_cached_partial(path, context)
|
47
|
+
|
48
|
+
context.stack do
|
49
|
+
context["include"] = parse_params(context) if @params
|
50
|
+
begin
|
51
|
+
partial.render!(context)
|
52
|
+
rescue Liquid::Error => e
|
53
|
+
e.template_name = path
|
54
|
+
e.markup_context = "included " if e.markup_context.nil?
|
55
|
+
raise e
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
class StyleTag < Liquid::Tag
|
62
|
+
def render(context)
|
63
|
+
site = context.registers[:site]
|
64
|
+
|
65
|
+
bookshop_scss_files = []
|
66
|
+
site.config['bookshop_locations']&.each do |location|
|
67
|
+
components_loc = Pathname.new(location + "/").cleanpath.to_s
|
68
|
+
scss_files = Dir.glob(components_loc + "/**/*.scss")&.collect do |scss_file|
|
69
|
+
scss_file.sub!(components_loc+"/", '').sub!(".scss", '')
|
70
|
+
end
|
71
|
+
bookshop_scss_files.push(*scss_files)
|
72
|
+
end
|
73
|
+
|
74
|
+
bookshop_scss_files = bookshop_scss_files&.collect do |file|
|
75
|
+
"@import '#{file}';"
|
76
|
+
end
|
77
|
+
|
78
|
+
output_css = if Jekyll.env == "production"
|
79
|
+
bookshop_scss_files.join("")
|
80
|
+
else
|
81
|
+
"html:not([data-bookshop-hmr]) {#{bookshop_scss_files.join("")}}"
|
82
|
+
end
|
83
|
+
|
84
|
+
output_css
|
85
|
+
end
|
31
86
|
end
|
32
87
|
|
33
88
|
class Styles
|
89
|
+
|
90
|
+
# Add the paths to find bookshop's styles
|
34
91
|
def self.open_bookshop(site)
|
35
|
-
|
36
|
-
|
92
|
+
bookshop_locations = site.config['bookshop_locations']&.collect do |location|
|
93
|
+
Pathname.new(location + "/").cleanpath.to_s
|
94
|
+
end
|
95
|
+
|
96
|
+
site.config['watch_dirs'] ||= [] # Paired with CloudCannon/jekyll-watch
|
97
|
+
site.config['watch_dirs'].push(*bookshop_locations);
|
98
|
+
|
37
99
|
site.config['sass'] ||= {}
|
38
100
|
site.config['sass']['load_paths'] ||= []
|
39
|
-
site.config['sass']['load_paths'].push(
|
101
|
+
site.config['sass']['load_paths'].push(*bookshop_locations)
|
40
102
|
end
|
41
103
|
end
|
42
104
|
|
@@ -62,7 +124,8 @@ module JekyllBookshop
|
|
62
124
|
end
|
63
125
|
end
|
64
126
|
|
65
|
-
Liquid::Template.register_tag("
|
127
|
+
Liquid::Template.register_tag("bookshop", JekyllBookshop::Tag)
|
128
|
+
Liquid::Template.register_tag("bookshop_scss", JekyllBookshop::StyleTag)
|
66
129
|
|
67
130
|
Liquid::Template.register_filter(JekyllBookshop::Filters)
|
68
131
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-bookshop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0.pre.alpha.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Liam Bigelow
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-05-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -30,7 +30,7 @@ dependencies:
|
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '5.0'
|
33
|
-
description:
|
33
|
+
description:
|
34
34
|
email:
|
35
35
|
- liam@cloudcannon.com
|
36
36
|
executables: []
|
@@ -43,7 +43,7 @@ homepage: https://github.com/cloudcannon/bookshop
|
|
43
43
|
licenses:
|
44
44
|
- MIT
|
45
45
|
metadata: {}
|
46
|
-
post_install_message:
|
46
|
+
post_install_message:
|
47
47
|
rdoc_options: []
|
48
48
|
require_paths:
|
49
49
|
- lib
|
@@ -54,12 +54,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
54
54
|
version: '0'
|
55
55
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
56
|
requirements:
|
57
|
-
- - "
|
57
|
+
- - ">"
|
58
58
|
- !ruby/object:Gem::Version
|
59
|
-
version:
|
59
|
+
version: 1.3.1
|
60
60
|
requirements: []
|
61
61
|
rubygems_version: 3.0.3
|
62
|
-
signing_key:
|
62
|
+
signing_key:
|
63
63
|
specification_version: 4
|
64
64
|
summary: A Jekyll plugin to load components from bookshop
|
65
65
|
test_files: []
|