jekyll-heroicons 0.2 → 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: d75f8059ea7aa63207d3554a911705015944ad140535354c3488869f1b2c1276
4
- data.tar.gz: 3fa2aa1a5127b87a6c209d26e2a868eaf8eb4987a790f59401db1789f71e043d
3
+ metadata.gz: 3685591a1423c6c548b5e6a3381c8559a141c87c11e0e5c8db082bb5ba9df456
4
+ data.tar.gz: 4f4e3948c4d4b07d5bdd3f9c1974b7d50ec9c79e59749b5953df26f7069829e8
5
5
  SHA512:
6
- metadata.gz: 57e8044b126bd1fb9839ff9c8eed9e6e33d247c0ef376a2311d6cbbc409cf2d1d9fe619ad9a651d9384b400544f87e9123a34107cfb602bf1681ec99dfabc5c1
7
- data.tar.gz: 1091d7b8bd64b141ac8bb1ebf900f9be812179bf48f9198e6c45140c8e2a5e18dcb2d76da98810ce6199cb22d1b56c23d5a7e72ec7873e21c89023f99626a3c8
6
+ metadata.gz: aa85bec0a59401be1a498665dc13cbcd77935dcdedaa7e0cecefed90d3d679247e408e7694feb08a12b1c8839d82e2df72a55f7763fab379809d63e7901a5292
7
+ data.tar.gz: 7b616f08a1d3e57adb75dafcfb17b8aec4420cae5ac8be676e0c48e8b88ffdb00d296b5946d4332f1d58ad949fb477cbe45173f8090841bc146ae7828492438c
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
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.
5
+ ## 0.2.1
6
+ - Remove new line character from icon raw code.
3
7
  ## 0.2.0
4
8
  - Introduce Icon class to deal with different parameters that could be passed to vsg code.
5
9
  ## 0.1.1
@@ -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
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"
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'
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