jekyll-generate-favicons 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0449f6e35b1890f8779b393c75422d234d73768713e5eade37196bc752e0435f'
4
- data.tar.gz: e7176bc5a6afbfa4a065fca90f1b1b9b57778d07bc6d2fdca818b99328eea3bd
3
+ metadata.gz: 0a8f21da481afe81491424da144af6f308b408a7c6c1b60360ff57081e4b45c6
4
+ data.tar.gz: 031cb2240efd8c851e821f4670e1409b1d278434d743fb801c08c1875c400584
5
5
  SHA512:
6
- metadata.gz: ad9df4ee28755fd049f2ae46a1282a248d71aa8234d06c71227f68442ddd71a840841f0fa7f5ec37ac5fb4efb5e4a6e7236f70ff73e86ca528a4436cca8ebdc5
7
- data.tar.gz: 5a833a107ad29a316d011315e1088d9c9ec958a0403ddf42c3397129e02745b71e313f07aeff2e3490170022fb80087d59d65af1519d92ee8be36fc4406fc408
6
+ metadata.gz: b347bc5885ae0de3440a68517a5896e92cb8237ed6ba3665e95e82a36219ff12d44af15324de386fa4de13bfd363bc78c89aa94cc7e728539751541760bf7b0b
7
+ data.tar.gz: 0a6ac9db7e5b4c5c71c21268ae32266751b49070d2cb99e19c90acb4c5c7cecc1b2fed48e79c77ddf8f5d45492836e6f1d04c2a5fbf3250bb667ad75e9fae308
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module GenerateFavicons
3
- VERSION = "0.0.3".freeze
3
+ VERSION = "0.0.4".freeze
4
4
  end
5
5
  end
@@ -6,49 +6,50 @@ require "jekyll-generate-favicons/utils"
6
6
 
7
7
  module Jekyll
8
8
  module GenerateFavicons
9
- class FaviconTag < Liquid::Tag
9
+ class FaviconTag < Liquid::Tag
10
10
 
11
- def initialize(tag_name, text, tokens)
12
- super
13
- end
11
+ DEFAULT_PATH = "assets/img/favicons".freeze
14
12
 
15
- def render(context)
16
- site = context.registers[:site]
17
- baseurl = site.config["baseurl"]
13
+ def render(context)
14
+ site = context.registers[:site]
15
+ baseurl = site.config["baseurl"]
18
16
 
19
- icon_file = site.config["icon"]
17
+ icon_file = site.config["icon"]
20
18
 
21
- apple_icon_file = site.config["apple_touch_icon"]
19
+ apple_icon_file = site.config["apple_touch_icon"]
22
20
 
23
- s = StringIO.new
24
- if icon_file
25
- icon_path, _ = Jekyll::GenerateFavicons::find_icon_file(site, icon_file)
26
- s << "<link rel=\"icon\" type=\"image/x-icon\" sizes=\"48x48\" href=\"#{baseurl}/favicon.ico\">\n"
27
- s << "<link rel=\"icon\" type=\"image/svg+xml\" sizes=\"any\" href=\"#{baseurl}/#{icon_path}\">\n"
28
- end
21
+ s = StringIO.new
22
+ if icon_file
23
+ icon_path, _ = Jekyll::GenerateFavicons::find_icon_file(site, icon_file)
24
+ s << "<link rel=\"icon\" type=\"image/x-icon\" sizes=\"48x48\" href=\"#{baseurl}/favicon.ico\">\n"
25
+ s << "<link rel=\"icon\" type=\"image/svg+xml\" sizes=\"any\" href=\"#{baseurl}/#{icon_path}\">\n"
26
+ end
29
27
 
30
- if apple_icon_file
31
- # apple_icon_file, _ = Jekyll::GenerateFavicons::find_icon_file(site, apple_icon_file)
28
+ if apple_icon_file
29
+ # apple_icon_file, _ = Jekyll::GenerateFavicons::find_icon_file(site, apple_icon_file)
30
+ default_path = Jekyll::GenerateFavicons::FaviconTag::DEFAULT_PATH
32
31
 
33
- [120, 152, 167, 180].each { |size|
34
- s << "<link rel=\"apple-touch-icon\" sizes=\"#{size}x#{size}\" href=\"#{site.baseurl}/assets/img/favicons/apple-touch-icon-#{size}.png\">\n"
35
- }
36
- end
37
- apple_mask_icon = site.config["apple_mask_icon"]
38
- if apple_mask_icon
39
- mask_src = apple_mask_icon["src"]
40
- mask_color = apple_mask_icon["color"]
41
- mask_color = "black" unless mask_color
32
+ [120, 152, 167, 180].each { |size|
33
+ icon_url = "#{site.baseurl}/#{default_path}/apple-touch-icon-#{size}.png"
34
+ icon_url = "#{site.baseurl}/apple-touch-icon.png" if size == 180
35
+ s << "<link rel=\"apple-touch-icon\" sizes=\"#{size}x#{size}\" href=\"#{icon_url}\">\n"
36
+ }
37
+ end
38
+ apple_mask_icon = site.config["apple_mask_icon"]
39
+ if apple_mask_icon
40
+ mask_src = apple_mask_icon["src"]
41
+ mask_color = apple_mask_icon["color"]
42
+ mask_color = "black" unless mask_color
42
43
 
43
- mask_src = apple_mask_icon unless mask_src
44
+ mask_src = apple_mask_icon unless mask_src
44
45
 
45
- icon_path, _ = Jekyll::GenerateFavicons::find_icon_file(site, mask_src)
46
- s << "<link rel=\"mask-icon\" href=\"#{baseurl}/#{icon_path}\" color=\"#{mask_color}\">"
47
- end
48
- s.string
46
+ icon_path, _ = Jekyll::GenerateFavicons::find_icon_file(site, mask_src)
47
+ s << "<link rel=\"mask-icon\" href=\"#{baseurl}/#{icon_path}\" color=\"#{mask_color}\">"
49
48
  end
49
+ s.string
50
50
  end
51
51
  end
52
+ end
52
53
 
53
54
  end
54
55
 
@@ -83,11 +84,15 @@ Jekyll::Hooks.register :site, :post_write do |site|
83
84
 
84
85
  _, src_file = Jekyll::GenerateFavicons::find_icon_file(site, apple_icon_file)
85
86
 
86
- dst_dir = File.join(site.dest, "assets/img/favicons")
87
+ dst_default_file = File.join(site.dest, "apple-touch-icon.png")
88
+
89
+ dst_dir = File.join(site.dest, Jekyll::GenerateFavicons::FaviconTag::DEFAULT_PATH)
87
90
  FileUtils.mkdir_p dst_dir
88
91
 
89
92
  [120, 152, 167, 180].each { |size|
90
93
  dst_file = File.join(dst_dir, "apple-touch-icon-#{size}.png")
94
+ # Default is big
95
+ dst_file = dst_default_file if size == 180
91
96
  unless File.exist?(dst_file)
92
97
  cmd = "magick #{src_file.shellescape} -resize #{size}x#{size} #{dst_file.shellescape}"
93
98
  system(cmd)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-generate-favicons
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Markus Sosnowski