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 +4 -4
- data/.rubocop.yml +4 -1
- data/README.md +55 -0
- data/Rakefile +3 -3
- data/lib/jekyll_og_image/configuration.rb +6 -2
- data/lib/jekyll_og_image/generator.rb +6 -3
- data/lib/jekyll_og_image/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea51d4a05adcc40de23c17b92e31139f154176500960782aa592864c71cbd334
|
4
|
+
data.tar.gz: a31cc539176deac7ad1e8fd0dea3b4fd45efd906a02d439766e8df82d80adceb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e3929c8ddee908ae78375186bacffab40da5813432d4a563ab4f61b5767b011cf69959842a0e2f05f4b6d899029d08aec3c9d531154162ef4de6cb2a4ba4c99
|
7
|
+
data.tar.gz: 2470a7946363160ebfebc258c5326089976b91a620d2bde2edc35c76149eec1a6d6f0d739812e8917e96b1910fa13a53c7c9e15198688207ebaef5f61a04cce2
|
data/.rubocop.yml
CHANGED
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 "
|
4
|
+
require "minitest/test_task"
|
5
5
|
|
6
|
-
|
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[
|
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" =>
|
54
|
-
"height" =>
|
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(
|
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
|
)
|