jekyll-generate-favicons 0.0.2 → 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 +4 -4
- data/README.md +28 -6
- data/lib/jekyll-generate-favicons/version.rb +1 -1
- data/lib/jekyll-generate-favicons.rb +38 -23
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a8f21da481afe81491424da144af6f308b408a7c6c1b60360ff57081e4b45c6
|
4
|
+
data.tar.gz: 031cb2240efd8c851e821f4670e1409b1d278434d743fb801c08c1875c400584
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b347bc5885ae0de3440a68517a5896e92cb8237ed6ba3665e95e82a36219ff12d44af15324de386fa4de13bfd363bc78c89aa94cc7e728539751541760bf7b0b
|
7
|
+
data.tar.gz: 0a6ac9db7e5b4c5c71c21268ae32266751b49070d2cb99e19c90acb4c5c7cecc1b2fed48e79c77ddf8f5d45492836e6f1d04c2a5fbf3250bb667ad75e9fae308
|
data/README.md
CHANGED
@@ -1,16 +1,38 @@
|
|
1
1
|
# Jekyll Generate Favicons
|
2
2
|
|
3
3
|
Want to keep your repository free from unnecessary amounts of assets?
|
4
|
-
|
4
|
+
Use this simple Jekyll plugin that generates common favicon formats from SVG files with ImageMagick.
|
5
5
|
|
6
|
-
|
6
|
+
#### 1. To enable, add the plugin into your Gemfile:
|
7
7
|
|
8
|
-
|
9
|
-
|
8
|
+
```ruby
|
9
|
+
group :jekyll_plugins do
|
10
|
+
gem 'jekyll-generate-favicons'
|
11
|
+
end
|
12
|
+
```
|
10
13
|
|
11
|
-
|
14
|
+
Putting the Gem in the `jekyll_plugins` group will directly enable it in Jekyll. If it is not working (e.g., in safe mode), you might have to add it also in your `_config.yml` file:
|
12
15
|
|
13
|
-
|
16
|
+
```yaml
|
17
|
+
plugins:
|
18
|
+
- jekyll-generate-favicons
|
19
|
+
```
|
20
|
+
|
21
|
+
#### 2. Define an `icon` and/or `apple_touch_icon` in your `_config.yml` to enable auto generation.
|
22
|
+
|
23
|
+
```yaml
|
24
|
+
icon: favicon.svg
|
25
|
+
apple_touch_icon: apple-touch-icon.svg
|
26
|
+
apple_mask_icon:
|
27
|
+
src: apple-mask-icon.svg
|
28
|
+
color: black
|
29
|
+
```
|
30
|
+
|
31
|
+
The plugin will search directly for the file or look it up under `assets/img`
|
32
|
+
|
33
|
+
`apple_mask_icon` will not transform the svg but only insert the reflected link the head. See [Apple Guidelines](https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariWebContent/pinnedTabs/pinnedTabs.html) for details.
|
34
|
+
|
35
|
+
#### 3. Include the generated files with a `favicons` tag in your html `<head>`:
|
14
36
|
|
15
37
|
{% favicons %}
|
16
38
|
|
@@ -6,39 +6,50 @@ require "jekyll-generate-favicons/utils"
|
|
6
6
|
|
7
7
|
module Jekyll
|
8
8
|
module GenerateFavicons
|
9
|
-
|
9
|
+
class FaviconTag < Liquid::Tag
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
DEFAULT_PATH = "assets/img/favicons".freeze
|
12
|
+
|
13
|
+
def render(context)
|
14
|
+
site = context.registers[:site]
|
15
|
+
baseurl = site.config["baseurl"]
|
14
16
|
|
15
|
-
|
16
|
-
site = context.registers[:site]
|
17
|
-
baseurl = site.config["baseurl"]
|
17
|
+
icon_file = site.config["icon"]
|
18
18
|
|
19
|
-
|
19
|
+
apple_icon_file = site.config["apple_touch_icon"]
|
20
20
|
|
21
|
-
|
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
|
22
27
|
|
23
|
-
|
24
|
-
|
25
|
-
|
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
|
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
|
29
31
|
|
30
|
-
|
31
|
-
|
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
|
32
43
|
|
33
|
-
|
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
|
44
|
+
mask_src = apple_mask_icon unless mask_src
|
37
45
|
|
38
|
-
|
46
|
+
icon_path, _ = Jekyll::GenerateFavicons::find_icon_file(site, mask_src)
|
47
|
+
s << "<link rel=\"mask-icon\" href=\"#{baseurl}/#{icon_path}\" color=\"#{mask_color}\">"
|
39
48
|
end
|
49
|
+
s.string
|
40
50
|
end
|
41
51
|
end
|
52
|
+
end
|
42
53
|
|
43
54
|
end
|
44
55
|
|
@@ -73,11 +84,15 @@ Jekyll::Hooks.register :site, :post_write do |site|
|
|
73
84
|
|
74
85
|
_, src_file = Jekyll::GenerateFavicons::find_icon_file(site, apple_icon_file)
|
75
86
|
|
76
|
-
|
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)
|
77
90
|
FileUtils.mkdir_p dst_dir
|
78
91
|
|
79
92
|
[120, 152, 167, 180].each { |size|
|
80
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
|
81
96
|
unless File.exist?(dst_file)
|
82
97
|
cmd = "magick #{src_file.shellescape} -resize #{size}x#{size} #{dst_file.shellescape}"
|
83
98
|
system(cmd)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-generate-favicons
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Markus Sosnowski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-02-
|
11
|
+
date: 2025-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|