jekyll-heroicons 0.2.1 → 0.3.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: 112fbd4869748edda881eba9c9ef2ee54455adc9bd02f9459f2b6f6283561242
4
- data.tar.gz: fd5b1f750f6a421d0ec7666a653c572d468cd7e3d062bc0dbe635641d8f40f87
3
+ metadata.gz: 3685591a1423c6c548b5e6a3381c8559a141c87c11e0e5c8db082bb5ba9df456
4
+ data.tar.gz: 4f4e3948c4d4b07d5bdd3f9c1974b7d50ec9c79e59749b5953df26f7069829e8
5
5
  SHA512:
6
- metadata.gz: fb3f32efc24439124b355dd25a95265c7253045864de3a4bf513b63d4c1cc1451bfb4c17602cdf1b192d260b6eebcc05e187128d8a2cef738e94f91c07bfefc2
7
- data.tar.gz: 6da0122ce4bac2056602a170e1a02d522e0d12f744fb7f76bc10b4b7832e2f391415b1658d5dce1e8a0879ccf895ab6395012126c48e097e478d01f0dd196120
6
+ metadata.gz: aa85bec0a59401be1a498665dc13cbcd77935dcdedaa7e0cecefed90d3d679247e408e7694feb08a12b1c8839d82e2df72a55f7763fab379809d63e7901a5292
7
+ data.tar.gz: 7b616f08a1d3e57adb75dafcfb17b8aec4420cae5ac8be676e0c48e8b88ffdb00d296b5946d4332f1d58ad949fb477cbe45173f8090841bc146ae7828492438c
data/CHANGELOG.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Jekyll-Heroicons
2
2
 
3
+ ## 0.3.0
4
+ - We can define in _config.yml default variant and default classes for each variant.
3
5
  ## 0.2.1
4
6
  - Remove new line character from icon raw code.
5
7
  ## 0.2.0
@@ -13,25 +13,15 @@ module Jekyll
13
13
  doc = Nokogiri::HTML::DocumentFragment.parse(file)
14
14
  svg = doc.at_css "svg"
15
15
 
16
- prepend_default_classes
17
-
18
16
  @options.each do |key, value|
19
17
  svg[key.to_s] = value
20
18
  end
21
19
 
22
- doc.to_html.strip
20
+ doc.to_html(save_with: 0).delete("\n")
23
21
  end
24
22
 
25
23
  private
26
24
 
27
- def prepend_default_classes
28
- if @options[:class]
29
- @options[:class] += " size-6"
30
- else
31
- @options[:class] = "size-6"
32
- end
33
- end
34
-
35
25
  def file
36
26
  @file ||= File.read(file_path).force_encoding("UTF-8")
37
27
  end
@@ -5,6 +5,6 @@ module Liquid; class Tag; end; end
5
5
 
6
6
  module Jekyll
7
7
  class Heroicons < Liquid::Tag
8
- VERSION = "0.2.1"
8
+ VERSION = "0.3.0"
9
9
  end
10
10
  end
@@ -17,7 +17,7 @@ module Jekyll
17
17
  SYNTAX = /\A(#{Liquid::VariableSignature}+)/
18
18
 
19
19
  # For interpolation, look for liquid variables
20
- VARIABLE = /\{\{\s*([\w]+\.?[\w]*)\s*\}\}/i
20
+ VARIABLE = /\{\{\s*(\w+\.?\w*)\s*\}\}/i
21
21
 
22
22
  # Copied from Liquid::TagAttributes to allow dashes in tag names:
23
23
  #
@@ -43,13 +43,36 @@ module Jekyll
43
43
 
44
44
  private
45
45
 
46
+ def config
47
+ return {} unless defined?(context) && context.registers[:site]
48
+
49
+ context.registers[:site].config["heroicons"]
50
+ end
51
+
46
52
  def prepare(markup)
47
53
  @symbol = symbol(markup)
48
54
  @options = string_to_hash(markup)
49
- @variant = if (match = markup.split("/")).length > 1
55
+ @variant = variant(markup)
56
+ prepend_default_classes
57
+ end
58
+
59
+ def variant(markup)
60
+ if (match = markup.split("/")).length > 1
50
61
  match.first
51
62
  elsif @options.key?(:variant)
52
63
  @options[:variant]
64
+ else
65
+ config["variant"]
66
+ end
67
+ end
68
+
69
+ def prepend_default_classes
70
+ return unless config.dig("default_class", @variant)
71
+
72
+ if @options[:class]
73
+ @options[:class] += " #{config.dig("default_class", @variant)}"
74
+ else
75
+ @options[:class] = config.dig("default_class", @variant)
53
76
  end
54
77
  end
55
78
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-heroicons
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stanislav (Stas) Katkov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-09-22 00:00:00.000000000 Z
11
+ date: 2024-09-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll