jekyll-og-image 1.0.5 → 1.1.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: 9fc4622681cf9b4953d6cbd7de3b661ebd217de44c08205656e395386b14e4c9
4
- data.tar.gz: 26b864c6981a1b353de1e8e97de690870e2f2d9c531d56dac1bf97bc2efc0cde
3
+ metadata.gz: b61ed8f290ff7d539d5797f7e176821c7467cf1e5c2405e54960909663271ef5
4
+ data.tar.gz: 300123301cf7fc2dc403cc8254181772983f036cb8a06e7e23374fda7861d62c
5
5
  SHA512:
6
- metadata.gz: 7285bbd3562d0e2fa67a1f92c639d2ffa505e73d0d6b58c705217e8e7eefbb5930b9c01fec2c5d267f3448cd012e76ed5f2748b639d62bde290d796ab87d31d8
7
- data.tar.gz: beb92471fe217bc7c105fb3924940fee58031306cf628aac36ff8a4b61841ebaee406c8a85ce6aa903563fe3ca8dd489d68d0b3018f9797e77cb76da209d08ef
6
+ metadata.gz: 6a29185631359c3b89faddc2b54187bbfd663b762c6533eb5909270e78320c04f313193ddd4c3e33652946865ef486b7bfaefbb941637a965d8fc02f8f6560b4
7
+ data.tar.gz: 83fa74112ac6747aa11a402913b6cd736c828f318b8a08ddf342d7aac8212a367b9c7028378fe681dbb8725dd44a6fcfe3ec379beb9e999e9e105cc6d52adb61
data/.rspec_status CHANGED
@@ -1,5 +1,5 @@
1
1
  example_id | status | run_time |
2
2
  ----------------------------------- | ------ | --------------- |
3
- ./spec/jekyll_og_image_spec.rb[1:1] | passed | 0.01883 seconds |
4
- ./spec/jekyll_og_image_spec.rb[1:2] | passed | 0.31382 seconds |
5
- ./spec/jekyll_og_image_spec.rb[1:3] | passed | 0.07861 seconds |
3
+ ./spec/jekyll_og_image_spec.rb[1:1] | passed | 0.01708 seconds |
4
+ ./spec/jekyll_og_image_spec.rb[1:2] | passed | 0.27293 seconds |
5
+ ./spec/jekyll_og_image_spec.rb[1:3] | passed | 0.06846 seconds |
data/README.md CHANGED
@@ -61,6 +61,31 @@ og_image:
61
61
 
62
62
  ![Example 1](examples/1.png)
63
63
 
64
+ ### Background Color and Text Colors
65
+
66
+ ```yaml
67
+ og_image:
68
+ output_dir: "/assets/og"
69
+ image: "/assets/images/igor.jpeg"
70
+ canvas:
71
+ background_color: "#F9E065"
72
+ header:
73
+ font_family: "Roboto, Bold"
74
+ color: "#333333"
75
+ content:
76
+ font_family: "Roboto, Regular"
77
+ color: "#333333"
78
+ force: false
79
+ domain: "igor.works"
80
+ border_bottom:
81
+ width: 20
82
+ fill:
83
+ - "#002B7F"
84
+ - "#FCD116"
85
+ - "#CE1126"
86
+ ```
87
+
88
+ ![Example 3](examples/3.png)
64
89
 
65
90
 
66
91
  ## Contributing
data/examples/3.png ADDED
Binary file
@@ -5,6 +5,18 @@ require "anyway_config"
5
5
  class JekyllOgImage::Config < Anyway::Config
6
6
  attr_config output_dir: "assets/images/og"
7
7
  attr_config force: false
8
+ attr_config verbose: false
9
+ attr_config canvas: {
10
+ background_color: "#FFFFFF"
11
+ }
12
+ attr_config header: {
13
+ font_family: "Helvetica, Bold",
14
+ color: "#2f313d"
15
+ }
16
+ attr_config content: {
17
+ font_family: "Helvetica, Regular",
18
+ color: "#535358"
19
+ }
8
20
  attr_config :image
9
21
  attr_config :domain
10
22
  attr_config border_bottom: {
@@ -12,6 +24,20 @@ class JekyllOgImage::Config < Anyway::Config
12
24
  fill: [ "#211F1F", "#F4CBB2", "#AD5C51", "#9CDAF1", "#7DBBE6" ]
13
25
  }
14
26
 
27
+ coerce_types canvas: {
28
+ background_color: { type: :string }
29
+ }
30
+
31
+ coerce_types header: {
32
+ font_family: { type: :string },
33
+ color: { type: :string }
34
+ }
35
+
36
+ coerce_types content: {
37
+ font_family: { type: :string },
38
+ color: { type: :string }
39
+ }
40
+
15
41
  coerce_types image: { type: :string }
16
42
 
17
43
  coerce_types border_bottom: {
@@ -15,10 +15,10 @@ class JekyllOgImage::Generator < Jekyll::Generator
15
15
  path = File.join(site.config["source"], base_path, "#{post.data['slug']}.png")
16
16
 
17
17
  if !File.exist?(path) || JekyllOgImage.config.force?
18
- Jekyll.logger.info "Jekyll Og Image:", "Generating image #{path}"
18
+ Jekyll.logger.info "Jekyll Og Image:", "Generating image #{path}" if JekyllOgImage.config.verbose?
19
19
  generate_image_for_post(site, post, path)
20
20
  else
21
- Jekyll.logger.info "Jekyll Og Image:", "Skipping image generation #{path} as it already exists."
21
+ Jekyll.logger.info "Jekyll Og Image:", "Skipping image generation #{path} as it already exists." if JekyllOgImage.config.verbose?
22
22
  end
23
23
 
24
24
  post.data["image"] ||= {
@@ -35,7 +35,9 @@ class JekyllOgImage::Generator < Jekyll::Generator
35
35
  def generate_image_for_post(site, post, path)
36
36
  date = post.date.strftime("%B %d, %Y")
37
37
 
38
- canvas = JekyllOgImage::Element::Canvas.new(1200, 600)
38
+ canvas = JekyllOgImage::Element::Canvas.new(1200, 600,
39
+ color: JekyllOgImage.config.canvas["background_color"]
40
+ )
39
41
  .border(JekyllOgImage.config.border_bottom["width"],
40
42
  position: :bottom,
41
43
  fill: JekyllOgImage.config.border_bottom["fill"]
@@ -53,16 +55,16 @@ class JekyllOgImage::Generator < Jekyll::Generator
53
55
 
54
56
  canvas = canvas.text(post.data["title"],
55
57
  width: JekyllOgImage.config.image ? 870 : 1040,
56
- color: "#2f313d",
58
+ color: JekyllOgImage.config.header["color"],
57
59
  dpi: 400,
58
- font: "Helvetica, Bold"
60
+ font: JekyllOgImage.config.header["font_family"]
59
61
  ) { |_canvas, _text| { x: 80, y: 100 } }
60
62
 
61
63
  canvas = canvas.text(date,
62
64
  gravity: :sw,
63
- color: "#535358",
65
+ color: JekyllOgImage.config.content["color"],
64
66
  dpi: 150,
65
- font: "Helvetica, Regular"
67
+ font: JekyllOgImage.config.content["font_family"]
66
68
  ) { |_canvas, _text| { x: 80, y: post.data["tags"].any? ? 150 : 100 } }
67
69
 
68
70
  if post.data["tags"].any?
@@ -70,14 +72,19 @@ class JekyllOgImage::Generator < Jekyll::Generator
70
72
 
71
73
  canvas = canvas.text(tags,
72
74
  gravity: :sw,
73
- color: "#535358",
75
+ color: JekyllOgImage.config.content["color"],
74
76
  dpi: 150,
75
- font: "Helvetica, Regular"
77
+ font: JekyllOgImage.config.content["font_family"]
76
78
  ) { |_canvas, _text| { x: 80, y: 100 } }
77
79
  end
78
80
 
79
81
  if JekyllOgImage.config.domain
80
- canvas = canvas.text(JekyllOgImage.config.domain, gravity: :se, color: "#535358", dpi: 150, font: "Helvetica, Regular") do |_canvas, _text|
82
+ canvas = canvas.text(JekyllOgImage.config.domain,
83
+ gravity: :se,
84
+ color: JekyllOgImage.config.content["color"],
85
+ dpi: 150,
86
+ font: JekyllOgImage.config.content["font_family"]
87
+ ) do |_canvas, _text|
81
88
  {
82
89
  x: 80,
83
90
  y: post.data["tags"].any? ? 150 : 100
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JekyllOgImage
4
- VERSION = "1.0.5"
4
+ VERSION = "1.1.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-og-image
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Alexandrov
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-06 00:00:00.000000000 Z
11
+ date: 2024-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll-seo-tag
@@ -86,7 +86,7 @@ dependencies:
86
86
  - - "<"
87
87
  - !ruby/object:Gem::Version
88
88
  version: '5.0'
89
- description:
89
+ description:
90
90
  email:
91
91
  - igor.alexandrov@gmail.com
92
92
  executables: []
@@ -102,7 +102,7 @@ files:
102
102
  - Rakefile
103
103
  - examples/1.png
104
104
  - examples/2.png
105
- - jekyll-og-image.gemspec
105
+ - examples/3.png
106
106
  - lib/jekyll-og-image.rb
107
107
  - lib/jekyll_og_image.rb
108
108
  - lib/jekyll_og_image/config.rb
@@ -118,7 +118,7 @@ licenses:
118
118
  - MIT
119
119
  metadata:
120
120
  homepage_uri: https://github.com/igor-alexandrov/jekyll-og-image
121
- post_install_message:
121
+ post_install_message:
122
122
  rdoc_options: []
123
123
  require_paths:
124
124
  - lib
@@ -133,8 +133,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
133
  - !ruby/object:Gem::Version
134
134
  version: '0'
135
135
  requirements: []
136
- rubygems_version: 3.5.4
137
- signing_key:
136
+ rubygems_version: 3.5.3
137
+ signing_key:
138
138
  specification_version: 4
139
139
  summary: Jekyll plugin to generate GitHub-style open graph images
140
140
  test_files: []
@@ -1,34 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "lib/jekyll_og_image/version"
4
-
5
- Gem::Specification.new do |spec|
6
- spec.name = "jekyll-og-image"
7
- spec.version = JekyllOgImage::VERSION
8
- spec.authors = [ "Igor Alexandrov" ]
9
- spec.email = [ "igor.alexandrov@gmail.com" ]
10
-
11
- spec.summary = "Jekyll plugin to generate GitHub-style open graph images"
12
- spec.homepage = "https://github.com/igor-alexandrov/jekyll-og-image"
13
- spec.license = "MIT"
14
- spec.required_ruby_version = ">= 3.2.0"
15
-
16
- spec.metadata["homepage_uri"] = spec.homepage
17
-
18
- # Specify which files should be added to the gem when it is released.
19
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
20
- spec.files = Dir.chdir(__dir__) do
21
- `git ls-files -z`.split("\x0").reject do |f|
22
- (File.expand_path(f) == __FILE__) ||
23
- f.start_with?(*%w[bin/ test/ spec/ features/ .git .github appveyor Gemfile])
24
- end
25
- end
26
-
27
- spec.require_paths = [ "lib" ]
28
-
29
- spec.add_dependency "jekyll-seo-tag", "~> 2.8"
30
- spec.add_dependency "zeitwerk", "~> 2.6"
31
- spec.add_dependency "anyway_config", "~> 2.6"
32
- spec.add_dependency "ruby-vips", "~> 2.2.0"
33
- spec.add_runtime_dependency "jekyll", ">= 3.4", "< 5.0"
34
- end