jekyll-og-image 1.5.0 → 2.0.0

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: 260918d98e574361037584e4d0d4097dd41fdcd3526386d3abfde00e2dc4b0f6
4
- data.tar.gz: e0c75eec8ddb3f3911aac2ef2b45687ecc1bb036057ed183802570a82f1a4922
3
+ metadata.gz: ea51d4a05adcc40de23c17b92e31139f154176500960782aa592864c71cbd334
4
+ data.tar.gz: a31cc539176deac7ad1e8fd0dea3b4fd45efd906a02d439766e8df82d80adceb
5
5
  SHA512:
6
- metadata.gz: 16f6da984ff3821513fdfd51eb9beb06e45bfb76c4530464ebc2f7d9164985a4583ec894258580ea125aed96b9ea489acc55332adc920cfda64e7f9f4c7ec3ee
7
- data.tar.gz: eb147ebfeb11d50a80370ced4b82b33c1b33730c6b087c3eddc2871b6aed570dac8014cd01f687711b4f316cdf51bb9cf37cbb8eb82b58e048bafa8f3a21bcac
6
+ metadata.gz: 5e3929c8ddee908ae78375186bacffab40da5813432d4a563ab4f61b5767b011cf69959842a0e2f05f4b6d899029d08aec3c9d531154162ef4de6cb2a4ba4c99
7
+ data.tar.gz: 2470a7946363160ebfebc258c5326089976b91a620d2bde2edc35c76149eec1a6d6f0d739812e8917e96b1910fa13a53c7c9e15198688207ebaef5f61a04cce2
data/.rubocop.yml CHANGED
@@ -7,4 +7,7 @@ AllCops:
7
7
 
8
8
  Style/FrozenStringLiteralComment:
9
9
  Enabled: true
10
- EnforcedStyle: always
10
+ EnforcedStyle: always
11
+
12
+ Rails/RefuteMethods:
13
+ Enabled: false
data/README.md CHANGED
@@ -22,6 +22,59 @@ plugins:
22
22
  - jekyll-og-image
23
23
  ```
24
24
 
25
+ This plugin requires `libvips` to be installed. If you are using GitHub Pages to host your Jekyll site, don't forget to install `libvips` before running `jekyll build`. See the example below.
26
+
27
+ ``` yaml
28
+ jobs:
29
+ build:
30
+ needs:
31
+ - lint
32
+ runs-on: ubuntu-latest
33
+ steps:
34
+ - name: Checkout
35
+ uses: actions/checkout@v4
36
+
37
+ - name: Setup Ruby
38
+ uses: ruby/setup-ruby@v1
39
+ with:
40
+ ruby-version: .ruby-version
41
+ bundler-cache: true
42
+
43
+ - name: Set Node.js 20.x
44
+ uses: actions/setup-node@v3
45
+ with:
46
+ node-version: 20.x
47
+
48
+ - name: Run install
49
+ uses: borales/actions-yarn@v4
50
+ with:
51
+ cmd: install
52
+
53
+ - name: Update apt
54
+ env:
55
+ DEBIAN_FRONTEND: noninteractive
56
+ run: sudo apt-get update -qq
57
+
58
+ - name: Install libvips
59
+ env:
60
+ DEBIAN_FRONTEND: noninteractive
61
+ run: sudo apt-get install --fix-missing libvips
62
+
63
+ - name: Setup Pages
64
+ id: pages
65
+ uses: actions/configure-pages@v5
66
+
67
+ - name: Build with Jekyll
68
+ run: ./bin/jekyll build --baseurl "${{ steps.pages.outputs.base_path }}"
69
+ env:
70
+ JEKYLL_ENV: production
71
+
72
+ - name: Upload artifact
73
+ # Automatically uploads an artifact from the './_site' directory by default
74
+ uses: actions/upload-pages-artifact@v3
75
+
76
+ ```
77
+
25
78
  ## Usage
26
79
 
27
80
  Jekyll OG Image works together with [jekyll-seo-tag](https://github.com/jekyll/jekyll-seo-tag) plugin. It automatically generates open graph images for posts and inserts them into the posts metadata.
@@ -44,6 +97,8 @@ The following configuration options are available:
44
97
  * `canvas` – The canvas configuration options:
45
98
  * `background_color` – The background color of the canvas. Default: `#FFFFFF`
46
99
  * `background_image` – The background image of the canvas. Default: `nil`
100
+ * `width` – The width of the generated image in pixels. Default: `1200`
101
+ * `height` – The height of the generated image in pixels. Default: `600`
47
102
 
48
103
  * `header` – The header configuration options:
49
104
  * `font_family` – The font family of the header text. Default: `Helvetica, Bold`
data/Rakefile CHANGED
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "bundler/gem_tasks"
4
- require "rspec/core/rake_task"
4
+ require "minitest/test_task"
5
5
 
6
- RSpec::Core::RakeTask.new(:spec)
6
+ Minitest::TestTask.create
7
7
 
8
8
  require "rubocop/rake_task"
9
9
 
10
10
  RuboCop::RakeTask.new
11
11
 
12
- task default: %i[spec rubocop]
12
+ task default: %i[test rubocop]
@@ -3,8 +3,8 @@
3
3
  # require "anyway_config"
4
4
 
5
5
  class JekyllOgImage::Configuration
6
- Canvas = Data.define(:background_color, :background_image) do
7
- def initialize(background_color: "#FFFFFF", background_image: nil)
6
+ Canvas = Data.define(:background_color, :background_image, :width, :height) do
7
+ def initialize(background_color: "#FFFFFF", background_image: nil, width: 1200, height: 600)
8
8
  super
9
9
  end
10
10
  end
@@ -53,6 +53,10 @@ class JekyllOgImage::Configuration
53
53
  @raw_config["collections"] || [ "posts" ]
54
54
  end
55
55
 
56
+ def enabled?
57
+ @raw_config["enabled"].nil? ? true : @raw_config["enabled"]
58
+ end
59
+
56
60
  def output_dir
57
61
  @raw_config["output_dir"] || "assets/images/og"
58
62
  end
@@ -36,6 +36,7 @@ class JekyllOgImage::Generator < Jekyll::Generator
36
36
  # rubocop:enable Layout/ElseAlignment
37
37
  File.basename(item.name, File.extname(item.name))
38
38
  end
39
+
39
40
  slug = item.data["slug"] || Jekyll::Utils.slugify(item.data["title"] || fallback_basename)
40
41
  image_filename = "#{slug}.png"
41
42
  absolute_image_path = File.join(absolute_output_dir, image_filename)
@@ -50,8 +51,8 @@ class JekyllOgImage::Generator < Jekyll::Generator
50
51
 
51
52
  item.data["image"] ||= {
52
53
  "path" => relative_image_path,
53
- "width" => 1200,
54
- "height" => 600,
54
+ "width" => JekyllOgImage.config.canvas.width,
55
+ "height" => JekyllOgImage.config.canvas.height,
55
56
  "alt" => item.data["title"]
56
57
  }
57
58
  end
@@ -76,6 +77,8 @@ class JekyllOgImage::Generator < Jekyll::Generator
76
77
  def generate_image_for_document(site, item, path, base_config)
77
78
  config = base_config.merge!(item.data["og_image"] || {})
78
79
 
80
+ return unless config.enabled?
81
+
79
82
  canvas = generate_canvas(site, config)
80
83
  canvas = add_border_bottom(canvas, config) if config.border_bottom
81
84
  canvas = add_image(canvas, File.read(File.join(site.config["source"], config.image))) if config.image
@@ -93,7 +96,7 @@ class JekyllOgImage::Generator < Jekyll::Generator
93
96
  File.exist?(bg_path) ? File.read(bg_path) : nil
94
97
  end
95
98
 
96
- JekyllOgImage::Element::Canvas.new(1200, 600,
99
+ JekyllOgImage::Element::Canvas.new(JekyllOgImage.config.canvas.width, JekyllOgImage.config.canvas.height,
97
100
  background_color: config.canvas.background_color,
98
101
  background_image: background_image
99
102
  )
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JekyllOgImage
4
- VERSION = "1.5.0"
4
+ VERSION = "2.0.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-og-image
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Alexandrov