bridgetown-seo-tag 6.0.0 → 7.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: f52feeb06f0b0cc5bc8a893251e22db438727808592d79027c2069a2c36c05ef
4
- data.tar.gz: 68a1b3dce65f5b959de19d2da22611be530cc4ab9fed9bc366e7d052eadbd2ba
3
+ metadata.gz: 154d11944043c471b5c83517d772b6120665e4700cdbf20cc7c07fccef24b41e
4
+ data.tar.gz: 8924ae3e584fb4b6287583f72c6bda7ae26120dbb0c7f265ff3331abd95c3745
5
5
  SHA512:
6
- metadata.gz: 2251e9c40bb873fd729e7e74b7f8124a911d85a79ea7f0d9ebd0ad1088cfbee3ebba23c6149a648a37bec38208b8318999e0afc3f0e722470d8540f515204b5c
7
- data.tar.gz: c1620483b79ac3cc063fd595d42b64f5dc4faa96cbcc78c59243d6d62577f6c8537c59da83d093c58b15bca90987a7043f35b69d01bf4a141ce7d75ee54ad462
6
+ metadata.gz: c3528d9b3b5f40a43184fd349cc05490d8d81651210b761c863de190ef160beaca1013c337e5f1e9a1d9ad6f28b35f02561ef8f8a3f1a0e67aae6de2fa4ba30c
7
+ data.tar.gz: a9f3f18665e1ebf300c7ad9b43a31fa23281435f2f9d15d484c66b11a43e0e73bbe5d850d2bf3032498c51fab6851534e748f6a28cb38554ace25ba7286380a4
@@ -0,0 +1,32 @@
1
+ name: Tests
2
+
3
+ on:
4
+ pull_request:
5
+ branches:
6
+ - "*"
7
+ push:
8
+ branches:
9
+ - master
10
+
11
+ jobs:
12
+ build:
13
+ runs-on: ubuntu-latest
14
+ strategy:
15
+ matrix:
16
+ ruby_version: [3.1.3, 3.2.0, 3.3.0, 3.4.0]
17
+ bridgetown_version: [1.3.4]
18
+ continue-on-error: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'debug' }}
19
+ # Has to be top level to cache properly
20
+ env:
21
+ BUNDLE_JOBS: 3
22
+ BUNDLE_PATH: "vendor/bundle"
23
+ BRIDGETOWN_VERSION: ${{ matrix.bridgetown_version }}
24
+ steps:
25
+ - uses: actions/checkout@master
26
+ - name: Setup Ruby
27
+ uses: ruby/setup-ruby@v1
28
+ with:
29
+ ruby-version: ${{ matrix.ruby_version }}
30
+ bundler-cache: true
31
+ - name: Test with Rake
32
+ run: script/cibuild
data/.gitignore CHANGED
@@ -1,7 +1,6 @@
1
1
  *.gem
2
2
  .bundle
3
3
  .yardoc
4
- Gemfile.lock
5
4
  pkg
6
5
  spec/reports/
7
6
  spec/fixtures/.bridgetown-cache
data/.rubocop.yml CHANGED
@@ -5,7 +5,7 @@ inherit_gem:
5
5
  rubocop-bridgetown: .rubocop.yml
6
6
 
7
7
  AllCops:
8
- TargetRubyVersion: 2.7
8
+ TargetRubyVersion: 3.1
9
9
  Exclude:
10
10
  - vendor/**/*
11
11
 
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 7.0.0 / 2025-08-15
4
+
5
+ - Add support for Bridgetown 2.0
6
+ - minimum requirement of Ruby 3.1
7
+ - Refactor internals so `Bridgetown::SeoTag` is a module, with a `LiquidTag` class inside
8
+ - Add GH workflow and fix failing items (@jclusso)
9
+ - Parse Mastodon handle to add attribution and verification metadata (@goulvench)
10
+
3
11
  ## 6.0.0 / 2023-01-08
4
12
 
5
13
  - Fix bug where prev/next rel links for paginated pages were missing
data/Gemfile CHANGED
@@ -4,4 +4,9 @@ source "https://rubygems.org"
4
4
 
5
5
  gemspec
6
6
 
7
- gem "bridgetown", ENV["BRIDGETOWN_VERSION"] if ENV["BRIDGETOWN_VERSION"]
7
+ gem "bridgetown", "2.0.0.beta6"
8
+ gem "bundler", ">= 1.15"
9
+ gem "html-proofer", "~> 3.7"
10
+ gem "rake", "~> 13.0"
11
+ gem "rspec", "~> 3.5"
12
+ gem "rubocop-bridgetown", "~> 0.3"
data/Gemfile.lock ADDED
@@ -0,0 +1,256 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ bridgetown-seo-tag (7.0.0)
5
+ bridgetown (>= 1.3)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ activesupport (7.2.2.2)
11
+ base64
12
+ benchmark (>= 0.3)
13
+ bigdecimal
14
+ concurrent-ruby (~> 1.0, >= 1.3.1)
15
+ connection_pool (>= 2.2.5)
16
+ drb
17
+ i18n (>= 1.6, < 2)
18
+ logger (>= 1.4.2)
19
+ minitest (>= 5.1)
20
+ securerandom (>= 0.3)
21
+ tzinfo (~> 2.0, >= 2.0.5)
22
+ addressable (2.8.7)
23
+ public_suffix (>= 2.0.2, < 7.0)
24
+ amazing_print (1.8.1)
25
+ ast (2.4.3)
26
+ base64 (0.3.0)
27
+ benchmark (0.4.1)
28
+ bigdecimal (3.2.2)
29
+ bridgetown (2.0.0.beta6)
30
+ bridgetown-builder (= 2.0.0.beta6)
31
+ bridgetown-core (= 2.0.0.beta6)
32
+ bridgetown-foundation (= 2.0.0.beta6)
33
+ bridgetown-paginate (= 2.0.0.beta6)
34
+ bridgetown-builder (2.0.0.beta6)
35
+ bridgetown-core (= 2.0.0.beta6)
36
+ bridgetown-core (2.0.0.beta6)
37
+ activesupport (>= 6.0, < 8.0)
38
+ addressable (~> 2.4)
39
+ amazing_print (~> 1.2)
40
+ bridgetown-foundation (= 2.0.0.beta6)
41
+ csv (~> 3.2)
42
+ dry-inflector (>= 1.0)
43
+ erubi (~> 1.9)
44
+ faraday (~> 2.0)
45
+ faraday-follow_redirects (~> 0.3)
46
+ i18n (~> 1.0)
47
+ irb (>= 1.14)
48
+ kramdown (~> 2.1)
49
+ kramdown-parser-gfm (~> 1.0)
50
+ liquid (>= 5.0, < 5.5)
51
+ listen (~> 3.0)
52
+ rack (>= 3.0)
53
+ rackup (~> 2.0)
54
+ rake (>= 13.0)
55
+ roda (~> 3.46)
56
+ rouge (>= 3.0, < 5.0)
57
+ serbea (~> 2.1)
58
+ signalize (~> 1.3)
59
+ streamlined (>= 0.6.0)
60
+ thor (~> 1.1)
61
+ tilt (~> 2.0)
62
+ zeitwerk (~> 2.5)
63
+ bridgetown-foundation (2.0.0.beta6)
64
+ hash_with_dot_access (~> 2.0)
65
+ inclusive (~> 1.0)
66
+ zeitwerk (~> 2.5)
67
+ bridgetown-paginate (2.0.0.beta6)
68
+ bridgetown-core (= 2.0.0.beta6)
69
+ cgi (0.5.0)
70
+ concurrent-ruby (1.3.5)
71
+ connection_pool (2.5.3)
72
+ csv (3.3.5)
73
+ date (3.4.1)
74
+ diff-lcs (1.6.2)
75
+ drb (2.2.3)
76
+ dry-inflector (1.2.0)
77
+ erb (4.0.4)
78
+ cgi (>= 0.3.3)
79
+ erubi (1.13.1)
80
+ ethon (0.16.0)
81
+ ffi (>= 1.15.0)
82
+ faraday (2.13.4)
83
+ faraday-net_http (>= 2.0, < 3.5)
84
+ json
85
+ logger
86
+ faraday-follow_redirects (0.3.0)
87
+ faraday (>= 1, < 3)
88
+ faraday-net_http (3.4.1)
89
+ net-http (>= 0.5.0)
90
+ ffi (1.17.2-aarch64-linux-gnu)
91
+ ffi (1.17.2-aarch64-linux-musl)
92
+ ffi (1.17.2-arm-linux-gnu)
93
+ ffi (1.17.2-arm-linux-musl)
94
+ ffi (1.17.2-arm64-darwin)
95
+ ffi (1.17.2-x86_64-darwin)
96
+ ffi (1.17.2-x86_64-linux-gnu)
97
+ ffi (1.17.2-x86_64-linux-musl)
98
+ hash_with_dot_access (2.1.1)
99
+ html-proofer (3.19.4)
100
+ addressable (~> 2.3)
101
+ mercenary (~> 0.3)
102
+ nokogiri (~> 1.13)
103
+ parallel (~> 1.10)
104
+ rainbow (~> 3.0)
105
+ typhoeus (~> 1.3)
106
+ yell (~> 2.0)
107
+ i18n (1.14.7)
108
+ concurrent-ruby (~> 1.0)
109
+ inclusive (1.0.0)
110
+ io-console (0.8.1)
111
+ irb (1.15.2)
112
+ pp (>= 0.6.0)
113
+ rdoc (>= 4.0.0)
114
+ reline (>= 0.4.2)
115
+ json (2.13.2)
116
+ kramdown (2.5.1)
117
+ rexml (>= 3.3.9)
118
+ kramdown-parser-gfm (1.1.0)
119
+ kramdown (~> 2.0)
120
+ language_server-protocol (3.17.0.5)
121
+ lint_roller (1.1.0)
122
+ liquid (5.4.0)
123
+ listen (3.9.0)
124
+ rb-fsevent (~> 0.10, >= 0.10.3)
125
+ rb-inotify (~> 0.9, >= 0.9.10)
126
+ logger (1.7.0)
127
+ mercenary (0.4.0)
128
+ minitest (5.25.5)
129
+ net-http (0.6.0)
130
+ uri
131
+ nokogiri (1.18.9-aarch64-linux-gnu)
132
+ racc (~> 1.4)
133
+ nokogiri (1.18.9-aarch64-linux-musl)
134
+ racc (~> 1.4)
135
+ nokogiri (1.18.9-arm-linux-gnu)
136
+ racc (~> 1.4)
137
+ nokogiri (1.18.9-arm-linux-musl)
138
+ racc (~> 1.4)
139
+ nokogiri (1.18.9-arm64-darwin)
140
+ racc (~> 1.4)
141
+ nokogiri (1.18.9-x86_64-darwin)
142
+ racc (~> 1.4)
143
+ nokogiri (1.18.9-x86_64-linux-gnu)
144
+ racc (~> 1.4)
145
+ nokogiri (1.18.9-x86_64-linux-musl)
146
+ racc (~> 1.4)
147
+ parallel (1.27.0)
148
+ parser (3.3.9.0)
149
+ ast (~> 2.4.1)
150
+ racc
151
+ pp (0.6.2)
152
+ prettyprint
153
+ prettyprint (0.2.0)
154
+ prism (1.4.0)
155
+ psych (5.2.6)
156
+ date
157
+ stringio
158
+ public_suffix (6.0.2)
159
+ racc (1.8.1)
160
+ rack (3.2.0)
161
+ rackup (2.2.1)
162
+ rack (>= 3)
163
+ rainbow (3.1.1)
164
+ rake (13.3.0)
165
+ rb-fsevent (0.11.2)
166
+ rb-inotify (0.11.1)
167
+ ffi (~> 1.0)
168
+ rdoc (6.14.2)
169
+ erb
170
+ psych (>= 4.0.0)
171
+ regexp_parser (2.11.2)
172
+ reline (0.6.2)
173
+ io-console (~> 0.5)
174
+ rexml (3.4.1)
175
+ roda (3.95.0)
176
+ rack
177
+ rouge (4.6.0)
178
+ rspec (3.13.1)
179
+ rspec-core (~> 3.13.0)
180
+ rspec-expectations (~> 3.13.0)
181
+ rspec-mocks (~> 3.13.0)
182
+ rspec-core (3.13.5)
183
+ rspec-support (~> 3.13.0)
184
+ rspec-expectations (3.13.5)
185
+ diff-lcs (>= 1.2.0, < 2.0)
186
+ rspec-support (~> 3.13.0)
187
+ rspec-mocks (3.13.5)
188
+ diff-lcs (>= 1.2.0, < 2.0)
189
+ rspec-support (~> 3.13.0)
190
+ rspec-support (3.13.4)
191
+ rubocop (1.79.2)
192
+ json (~> 2.3)
193
+ language_server-protocol (~> 3.17.0.2)
194
+ lint_roller (~> 1.1.0)
195
+ parallel (~> 1.10)
196
+ parser (>= 3.3.0.2)
197
+ rainbow (>= 2.2.2, < 4.0)
198
+ regexp_parser (>= 2.9.3, < 3.0)
199
+ rubocop-ast (>= 1.46.0, < 2.0)
200
+ ruby-progressbar (~> 1.7)
201
+ unicode-display_width (>= 2.4.0, < 4.0)
202
+ rubocop-ast (1.46.0)
203
+ parser (>= 3.3.7.2)
204
+ prism (~> 1.4)
205
+ rubocop-bridgetown (0.6.1)
206
+ rubocop (~> 1.23)
207
+ rubocop-performance (~> 1.12)
208
+ rubocop-performance (1.25.0)
209
+ lint_roller (~> 1.1)
210
+ rubocop (>= 1.75.0, < 2.0)
211
+ rubocop-ast (>= 1.38.0, < 2.0)
212
+ ruby-progressbar (1.13.0)
213
+ securerandom (0.4.1)
214
+ serbea (2.2.0)
215
+ erubi (>= 1.10)
216
+ tilt (~> 2.0)
217
+ signalize (1.3.0)
218
+ concurrent-ruby (~> 1.2)
219
+ streamlined (0.6.0)
220
+ serbea (>= 2.1)
221
+ zeitwerk (~> 2.5)
222
+ stringio (3.1.7)
223
+ thor (1.4.0)
224
+ tilt (2.6.1)
225
+ typhoeus (1.4.1)
226
+ ethon (>= 0.9.0)
227
+ tzinfo (2.0.6)
228
+ concurrent-ruby (~> 1.0)
229
+ unicode-display_width (3.1.5)
230
+ unicode-emoji (~> 4.0, >= 4.0.4)
231
+ unicode-emoji (4.0.4)
232
+ uri (1.0.3)
233
+ yell (2.2.2)
234
+ zeitwerk (2.6.18)
235
+
236
+ PLATFORMS
237
+ aarch64-linux-gnu
238
+ aarch64-linux-musl
239
+ arm-linux-gnu
240
+ arm-linux-musl
241
+ arm64-darwin
242
+ x86_64-darwin
243
+ x86_64-linux-gnu
244
+ x86_64-linux-musl
245
+
246
+ DEPENDENCIES
247
+ bridgetown (= 2.0.0.beta6)
248
+ bridgetown-seo-tag!
249
+ bundler (>= 1.15)
250
+ html-proofer (~> 3.7)
251
+ rake (~> 13.0)
252
+ rspec (~> 3.5)
253
+ rubocop-bridgetown (~> 0.3)
254
+
255
+ BUNDLED WITH
256
+ 2.5.6
data/README.md CHANGED
@@ -4,21 +4,31 @@ A Bridgetown plugin to add metadata tags for search engines and social networks
4
4
 
5
5
  [![Gem Version](https://badge.fury.io/rb/bridgetown-seo-tag.svg)](https://badge.fury.io/rb/bridgetown-seo-tag)
6
6
 
7
- ## Installation
7
+ ## Installation for Bridgetown 1.2+
8
8
 
9
9
  Run this command to add this plugin to your site's Gemfile:
10
10
 
11
11
  ```shell
12
- $ bundle add bridgetown-seo-tag -g bridgetown_plugins
12
+ $ bundle add bridgetown-seo-tag
13
13
  ```
14
14
 
15
15
  Or simply add this line to your Gemfile:
16
16
 
17
17
  ```ruby
18
- gem 'bridgetown-seo-tag', group: "bridgetown_plugins"
18
+ gem 'bridgetown-seo-tag'
19
19
  ```
20
20
 
21
- And then add the Liquid tag to your HTML head:
21
+ And then add the initializer to your configuration in `config/initializers.rb`:
22
+
23
+ ```ruby
24
+ init :"bridgetown-seo-tag"
25
+ ```
26
+
27
+ (For Bridgetown 1.1 or earlier, [read these instructions](https://github.com/bridgetownrb/bridgetown-seo-tag/tree/v5.0.0).)
28
+
29
+ ## Summary
30
+
31
+ Add the Liquid tag to your HTML head:
22
32
 
23
33
  ```liquid
24
34
  {% seo %}
@@ -38,8 +48,6 @@ You can use the `seo` helper in Ruby templates as well:
38
48
  <%= seo title: false %>
39
49
  ```
40
50
 
41
- ## Summary
42
-
43
51
  Bridgetown SEO Tag adds the following meta tags to your site:
44
52
 
45
53
  * Page title, with site title or description appended (optional)
@@ -47,6 +55,7 @@ Bridgetown SEO Tag adds the following meta tags to your site:
47
55
  * Canonical URL
48
56
  * Next and previous URLs on paginated pages
49
57
  * [Open Graph](https://ogp.me/) title, description, site title, and URL (for Facebook, LinkedIn, etc.)
58
+ * Mastodon [verification](https://docs.joinmastodon.org/user/profile/#verification) and [attribution](https://blog.joinmastodon.org/2024/07/highlighting-journalism-on-mastodon/)
50
59
  * [Twitter Summary Card](https://developer.twitter.com/en/docs/tweets/optimize-with-cards/guides/getting-started) metadata
51
60
 
52
61
  While you could theoretically add the necessary metadata tags yourself, Bridgetown SEO Tag provides a battle-tested template of crowdsourced best-practices.
@@ -67,6 +76,8 @@ The SEO tag will respect any of the following if included in your site's `site_m
67
76
  * `description` - A longer description used for the description meta tag. Also used as fallback for documents that don't provide their own `description` and as part of the home page title tag if `tagline` is not defined.
68
77
  * `author` - global author information (see [Advanced usage](https://github.com/bridgetownrb/bridgetown-seo-tag/wiki/Advanced-Usage#author-information))
69
78
 
79
+ * `mastodon` - Your Mastodon handle, to both verify your Mastodon profile, and link to your profile when someone shares your content on the network. If the page metadata contains a `mastodon` entry, it will take precedence over `site_metadata.yml`.
80
+
70
81
  * `twitter` - You can add a single Twitter handle to be used in Twitter card tags, like "bridgetownrb". Or you use a YAML mapping with additional details:
71
82
  * `twitter:card` - The site's default card type
72
83
  * `twitter:username` - The site's Twitter handle
@@ -117,7 +128,7 @@ The SEO tag will respect the following YAML front matter if included in a post,
117
128
 
118
129
  ### Setting a default image
119
130
 
120
- You can define a default image using [Front Matter defaults](https://www.bridgetownrb.com/docs/configuration/front-matter-defaults/) to provide a default Twitter Card or Open Graph image to all of your documents.
131
+ You can define a default image using [Front Matter defaults](https://www.bridgetownrb.com/docs/content/front-matter-defaults/) to provide a default Twitter Card or Open Graph image to all of your documents.
121
132
 
122
133
  Here is a very basic example, that you are encouraged to adapt to your needs:
123
134
 
@@ -11,17 +11,11 @@ Gem::Specification.new do |spec|
11
11
  spec.homepage = "https://github.com/bridgetownrb/bridgetown-seo-tag"
12
12
  spec.license = "MIT"
13
13
 
14
- spec.required_ruby_version = ">= 2.7.0"
14
+ spec.required_ruby_version = ">= 3.1.0"
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r!^(test|script|spec|features)/!) }
17
17
  spec.require_paths = ["lib"]
18
18
 
19
- spec.add_dependency "bridgetown", ">= 1.2.0.beta5", "< 2.0"
20
-
21
- spec.add_development_dependency "bundler", ">= 1.15"
22
- spec.add_development_dependency "html-proofer", "~> 3.7"
23
- spec.add_development_dependency "rake", "~> 13.0"
24
- spec.add_development_dependency "rspec", "~> 3.5"
25
- spec.add_development_dependency "rubocop-bridgetown", "~> 0.3"
19
+ spec.add_dependency "bridgetown", ">= 1.3"
26
20
  spec.metadata["rubygems_mfa_required"] = "true"
27
21
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bridgetown
4
- class SeoTag
4
+ module SeoTag
5
5
  # A drop representing the current page's author
6
6
  #
7
7
  # Author name will be pulled from:
@@ -55,7 +55,7 @@ module Bridgetown
55
55
  @resolved_author = sources.find { |s| !s.to_s.empty? }
56
56
  end
57
57
 
58
- # If resolved_author is a string, attempts to find coresponding author
58
+ # If resolved_author is a string, attempts to find corresponding author
59
59
  # metadata in `site.data.authors`
60
60
  #
61
61
  # Returns a hash representing additional metadata or an empty hash
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bridgetown
4
- class SeoTag
4
+ module SeoTag
5
5
  class Builder < Bridgetown::Builder
6
6
  def build
7
7
  helper "seo" do |title: true|
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bridgetown
4
- class SeoTag
4
+ module SeoTag
5
5
  class Drop < Bridgetown::Drops::Drop
6
6
  include Bridgetown::SeoTag::UrlHelper
7
7
 
@@ -10,7 +10,7 @@ module Bridgetown
10
10
  FORMAT_STRING_METHODS = [
11
11
  :markdownify, :strip_html, :normalize_whitespace, :escape_once,
12
12
  ].freeze
13
- HOMEPAGE_OR_ABOUT_REGEX = %r!^/(about/)?(index.html?)?$!.freeze
13
+ HOMEPAGE_OR_ABOUT_REGEX = %r!^/(about/)?(index.html?)?$!
14
14
 
15
15
  def initialize(text, context)
16
16
  @obj = {}
@@ -71,8 +71,6 @@ module Bridgetown
71
71
  page_title || site_title
72
72
  end
73
73
 
74
- return page_number + @title if page_number
75
-
76
74
  @title
77
75
  end
78
76
 
@@ -102,7 +100,7 @@ module Bridgetown
102
100
  end
103
101
 
104
102
  # Returns a Drop representing the page's image
105
- # Returns nil if the image has no path, to preserve backwards compatability
103
+ # Returns nil if the image has no path, to preserve backwards compatibility
106
104
  def image
107
105
  @image ||= ImageDrop.new(page: page, context: @context)
108
106
  @image if @image.path
@@ -189,16 +187,6 @@ module Bridgetown
189
187
  page["url"] =~ HOMEPAGE_OR_ABOUT_REGEX
190
188
  end
191
189
 
192
- def page_number
193
- return unless @context["paginator"] && @context["paginator"]["page"]
194
-
195
- current = @context["paginator"]["page"]
196
- total = @context["paginator"]["total_pages"]
197
- paginator_message = site["seo_paginator_message"] || "Page %<current>s of %<total>s for "
198
-
199
- format(paginator_message, current: current, total: total) if current > 1
200
- end
201
-
202
190
  attr_reader :context
203
191
 
204
192
  def fallback_data
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bridgetown
4
- class SeoTag
4
+ module SeoTag
5
5
  class Filters
6
6
  include Bridgetown::Filters
7
7
  include Liquid::StandardFilters
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bridgetown
4
- class SeoTag
4
+ module SeoTag
5
5
  # A drop representing the page image
6
6
  # The image path will be pulled from:
7
7
  #
@@ -24,7 +24,7 @@ module Bridgetown
24
24
  @context = context
25
25
  end
26
26
 
27
- # Called path for backwards compatability, this is really
27
+ # Called path for backwards compatibility, this is really
28
28
  # the escaped, absolute URL representing the page's image
29
29
  # Returns nil if no image path can be determined
30
30
  def path
@@ -0,0 +1,84 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bridgetown
4
+ module SeoTag
5
+ # A drop representing the current page's mastodon handle
6
+ #
7
+ # Mastodon handle will be pulled from:
8
+ #
9
+ # 1. The page's `mastodon` key
10
+ # 2. The `mastodon` key in the site config
11
+ class MastodonDrop < Bridgetown::Drops::Drop
12
+ HANDLE_REGEX = %r{\A@?(?<username>[^@]+)@(?<server>[^@]+)\z}
13
+
14
+ # Initialize a new MastodonDrop
15
+ #
16
+ # page - The page hash (e.g., Page#to_liquid)
17
+ # site - The Bridgetown::Drops::SiteDrop
18
+ def initialize(page: nil, site: nil)
19
+ raise ArgumentError unless page && site
20
+
21
+ @mutations = {}
22
+ @page = page
23
+ @site = site
24
+ end
25
+
26
+ def mastodon_handle
27
+ "@#{username}@#{server}" if handle?
28
+ end
29
+ alias_method :to_s, :mastodon_handle
30
+
31
+ def mastodon_url
32
+ "https://#{server}/@#{username}" if handle?
33
+ end
34
+
35
+ # Make the drop behave like a hash
36
+ def [](key)
37
+ mastodon_handle if key.to_sym == :mastodon
38
+ end
39
+
40
+ private
41
+
42
+ attr_reader :page, :site
43
+
44
+ # Finds the mastodon handle in page.metadata, or site.metadata
45
+ #
46
+ # Returns a string
47
+ def resolved_handle
48
+ return @resolved_handle if defined? @resolved_handle
49
+
50
+ sources = [page["mastodon"]]
51
+ sources << site.data.dig("site_metadata", "mastodon")
52
+ @resolved_handle = sources.find { |s| !s.to_s.empty? }
53
+ end
54
+
55
+ # Returns the username parsed from the resolved handle
56
+ def username
57
+ handle_hash["username"]
58
+ end
59
+
60
+ # Returns the server parsed from the resolved handle
61
+ def server
62
+ handle_hash["server"]
63
+ end
64
+
65
+ # Returns a hash containing username and server
66
+ # or an empty hash, if the handle cannot be parsed
67
+ def handle_hash
68
+ @handle_hash ||= case resolved_handle
69
+ when String
70
+ HANDLE_REGEX.match(resolved_handle)&.named_captures || {}
71
+ else
72
+ {}
73
+ end
74
+ end
75
+ # Since author_hash is aliased to fallback_data, any values in the hash
76
+ # will be exposed via the drop, allowing support for arbitrary metadata
77
+ alias_method :fallback_data, :handle_hash
78
+
79
+ def handle?
80
+ handle_hash != {}
81
+ end
82
+ end
83
+ end
84
+ end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bridgetown
4
- class SeoTag
4
+ module SeoTag
5
5
  # Mixin to share common URL-related methods between class
6
6
  module UrlHelper
7
7
  private
@@ -9,10 +9,10 @@ module Bridgetown
9
9
  # Determines if the given string is an absolute URL
10
10
  #
11
11
  # Returns true if an absolute URL.
12
- # Retruns false if it's a relative URL
12
+ # Returns false if it's a relative URL
13
13
  # Returns nil if it is not a string or can't be parsed as a URL
14
14
  def absolute_url?(string)
15
- return unless string
15
+ return false unless string
16
16
 
17
17
  Addressable::URI.parse(string).absolute?
18
18
  rescue Addressable::URI::InvalidURIError
@@ -1,10 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Prevent bundler errors
4
- module Liquid; class Tag; end; end # rubocop:disable Lint/EmptyClass
5
-
6
3
  module Bridgetown
7
- class SeoTag < Liquid::Tag
8
- VERSION = "6.0.0"
4
+ module SeoTag
5
+ VERSION = "7.0.0"
9
6
  end
10
7
  end
@@ -3,97 +3,98 @@
3
3
  require "bridgetown"
4
4
  require "bridgetown-seo-tag/version"
5
5
 
6
- module Bridgetown
7
- class SeoTag < Liquid::Tag
8
- autoload :AuthorDrop, "bridgetown-seo-tag/author_drop"
9
- autoload :ImageDrop, "bridgetown-seo-tag/image_drop"
10
- autoload :UrlHelper, "bridgetown-seo-tag/url_helper"
11
- autoload :Drop, "bridgetown-seo-tag/drop"
12
- autoload :Filters, "bridgetown-seo-tag/filters"
13
-
14
- attr_accessor :context
15
-
16
- # Matches all whitespace that follows either
17
- # 1. A '}', which closes a Liquid tag
18
- # 2. A '{', which opens a JSON block
19
- # 3. A '>' followed by a newline, which closes an XML tag or
20
- # 4. A ',' followed by a newline, which ends a JSON line
21
- # We will strip all of this whitespace to minify the template
22
- # We will not strip any whitespace if the next character is a '-'
23
- # so that we do not interfere with the HTML comment at the
24
- # very begining
25
- MINIFY_REGEX = %r!(?<=[{}]|[>,]\n)\s+(?\!-)!.freeze
26
-
27
- def initialize(_tag_name, text, _tokens)
28
- super
29
- @text = text
30
- end
6
+ module Bridgetown::SeoTag
7
+ autoload :AuthorDrop, "bridgetown-seo-tag/author_drop"
8
+ autoload :MastodonDrop, "bridgetown-seo-tag/mastodon_drop"
9
+ autoload :ImageDrop, "bridgetown-seo-tag/image_drop"
10
+ autoload :UrlHelper, "bridgetown-seo-tag/url_helper"
11
+ autoload :Drop, "bridgetown-seo-tag/drop"
12
+ autoload :Filters, "bridgetown-seo-tag/filters"
13
+ end
31
14
 
32
- def render(context)
33
- @context = context
34
- SeoTag.template.render!(payload, info)
35
- end
15
+ class Bridgetown::SeoTag::LiquidTag < Liquid::Tag
16
+ attr_accessor :context
17
+
18
+ # Matches all whitespace that follows either
19
+ # 1. A '}', which closes a Liquid tag
20
+ # 2. A '{', which opens a JSON block
21
+ # 3. A '>' followed by a newline, which closes an XML tag or
22
+ # 4. A ',' followed by a newline, which ends a JSON line
23
+ # We will strip all of this whitespace to minify the template
24
+ # We will not strip any whitespace if the next character is a '-'
25
+ # so that we do not interfere with the HTML comment at the
26
+ # very begining
27
+ MINIFY_REGEX = %r!(?<=[{}]|[>,]\n)\s+(?\!-)!
28
+
29
+ def initialize(_tag_name, text, _tokens)
30
+ super
31
+ @text = text
32
+ end
36
33
 
37
- private
34
+ def render(context)
35
+ @context = context
36
+ self.class.template.render!(payload, info)
37
+ end
38
38
 
39
- def options
40
- {
41
- "version" => Bridgetown::SeoTag::VERSION,
42
- "title" => title?,
43
- }
44
- end
39
+ private
45
40
 
46
- def payload
47
- if context.registers[:page].respond_to?(:paginator)
48
- paginator = context.registers[:page].paginator
49
- end
50
-
51
- # site_payload is an instance of UnifiedPayloadDrop
52
- Bridgetown::Utils.deep_merge_hashes(
53
- context.registers[:site].site_payload,
54
- "page" => context.registers[:page],
55
- "paginator" => paginator,
56
- "seo_tag" => drop
57
- )
58
- end
41
+ def options
42
+ {
43
+ "version" => Bridgetown::SeoTag::VERSION,
44
+ "title" => title?,
45
+ }
46
+ end
59
47
 
60
- def drop
61
- if context.registers[:site].liquid_renderer.respond_to?(:cache)
62
- Bridgetown::SeoTag::Drop.new(@text, context)
63
- else
64
- @drop ||= Bridgetown::SeoTag::Drop.new(@text, context)
65
- end
48
+ def payload
49
+ if context.registers[:page].respond_to?(:paginator)
50
+ paginator = context.registers[:page].paginator
66
51
  end
67
52
 
68
- def info
69
- {
70
- registers: {
71
- site: context.registers[:site],
72
- page: context.registers[:page],
73
- },
74
- filters: [Bridgetown::Filters],
75
- }
53
+ # site_payload is an instance of UnifiedPayloadDrop
54
+ Bridgetown::Utils.deep_merge_hashes(
55
+ context.registers[:site].site_payload,
56
+ "page" => context.registers[:page],
57
+ "paginator" => paginator,
58
+ "seo_tag" => drop
59
+ )
60
+ end
61
+
62
+ def drop
63
+ if context.registers[:site].liquid_renderer.respond_to?(:cache)
64
+ Bridgetown::SeoTag::Drop.new(@text, context)
65
+ else
66
+ @drop ||= Bridgetown::SeoTag::Drop.new(@text, context)
76
67
  end
68
+ end
69
+
70
+ def info
71
+ {
72
+ registers: {
73
+ site: context.registers[:site],
74
+ page: context.registers[:page],
75
+ },
76
+ filters: [Bridgetown::Filters],
77
+ }
78
+ end
77
79
 
78
- class << self
79
- def template
80
- @template ||= Liquid::Template.parse template_contents
81
- end
80
+ class << self
81
+ def template
82
+ @template ||= Liquid::Template.parse template_contents
83
+ end
82
84
 
83
- private
85
+ private
84
86
 
85
- def template_contents
86
- @template_contents ||= File.read(template_path).gsub(MINIFY_REGEX, "")
87
- end
87
+ def template_contents
88
+ @template_contents ||= File.read(template_path).gsub(MINIFY_REGEX, "")
89
+ end
88
90
 
89
- def template_path
90
- @template_path ||= File.expand_path "./template.html", File.dirname(__FILE__)
91
- end
91
+ def template_path
92
+ @template_path ||= File.expand_path "./template.html", File.dirname(__FILE__)
92
93
  end
93
94
  end
94
95
  end
95
96
 
96
- Liquid::Template.register_tag("seo", Bridgetown::SeoTag)
97
+ Liquid::Template.register_tag("seo", Bridgetown::SeoTag::LiquidTag)
97
98
  require "bridgetown-seo-tag/builder"
98
99
 
99
100
  Bridgetown.initializer :"bridgetown-seo-tag" do |config|
data/lib/template.html CHANGED
@@ -69,6 +69,11 @@
69
69
  <meta property="twitter:title" content="{{ seo_tag.page_title }}" />
70
70
  {% endif %}
71
71
 
72
+ {% if seo_tag.mastodon_handle %}
73
+ <meta name="fediverse:creator" content="{{ seo_tag.mastodon_handle }}" />
74
+ <link rel="me" href="{{ seo_tag.mastodon_url }}" />
75
+ {% endif %}
76
+
72
77
  {% if site.metadata.twitter %}
73
78
  <meta name="twitter:site" content="@{{ site.metadata.twitter.username | default: site.metadata.twitter | remove:'@' }}" />
74
79
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bridgetown-seo-tag
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.0
4
+ version: 7.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bridgetown Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-08 00:00:00.000000000 Z
11
+ date: 2025-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bridgetown
@@ -16,102 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 1.2.0.beta5
20
- - - "<"
21
- - !ruby/object:Gem::Version
22
- version: '2.0'
19
+ version: '1.3'
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
24
  - - ">="
28
25
  - !ruby/object:Gem::Version
29
- version: 1.2.0.beta5
30
- - - "<"
31
- - !ruby/object:Gem::Version
32
- version: '2.0'
33
- - !ruby/object:Gem::Dependency
34
- name: bundler
35
- requirement: !ruby/object:Gem::Requirement
36
- requirements:
37
- - - ">="
38
- - !ruby/object:Gem::Version
39
- version: '1.15'
40
- type: :development
41
- prerelease: false
42
- version_requirements: !ruby/object:Gem::Requirement
43
- requirements:
44
- - - ">="
45
- - !ruby/object:Gem::Version
46
- version: '1.15'
47
- - !ruby/object:Gem::Dependency
48
- name: html-proofer
49
- requirement: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - "~>"
52
- - !ruby/object:Gem::Version
53
- version: '3.7'
54
- type: :development
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - "~>"
59
- - !ruby/object:Gem::Version
60
- version: '3.7'
61
- - !ruby/object:Gem::Dependency
62
- name: rake
63
- requirement: !ruby/object:Gem::Requirement
64
- requirements:
65
- - - "~>"
66
- - !ruby/object:Gem::Version
67
- version: '13.0'
68
- type: :development
69
- prerelease: false
70
- version_requirements: !ruby/object:Gem::Requirement
71
- requirements:
72
- - - "~>"
73
- - !ruby/object:Gem::Version
74
- version: '13.0'
75
- - !ruby/object:Gem::Dependency
76
- name: rspec
77
- requirement: !ruby/object:Gem::Requirement
78
- requirements:
79
- - - "~>"
80
- - !ruby/object:Gem::Version
81
- version: '3.5'
82
- type: :development
83
- prerelease: false
84
- version_requirements: !ruby/object:Gem::Requirement
85
- requirements:
86
- - - "~>"
87
- - !ruby/object:Gem::Version
88
- version: '3.5'
89
- - !ruby/object:Gem::Dependency
90
- name: rubocop-bridgetown
91
- requirement: !ruby/object:Gem::Requirement
92
- requirements:
93
- - - "~>"
94
- - !ruby/object:Gem::Version
95
- version: '0.3'
96
- type: :development
97
- prerelease: false
98
- version_requirements: !ruby/object:Gem::Requirement
99
- requirements:
100
- - - "~>"
101
- - !ruby/object:Gem::Version
102
- version: '0.3'
26
+ version: '1.3'
103
27
  description:
104
28
  email: maintainers@bridgetownrb.com
105
29
  executables: []
106
30
  extensions: []
107
31
  extra_rdoc_files: []
108
32
  files:
33
+ - ".github/workflows/tests.yml"
109
34
  - ".gitignore"
110
35
  - ".rspec"
111
36
  - ".rubocop.yml"
112
37
  - ".rubocop_todo.yml"
113
38
  - CHANGELOG.md
114
39
  - Gemfile
40
+ - Gemfile.lock
115
41
  - LICENSE.txt
116
42
  - README.md
117
43
  - Rakefile
@@ -122,6 +48,7 @@ files:
122
48
  - lib/bridgetown-seo-tag/drop.rb
123
49
  - lib/bridgetown-seo-tag/filters.rb
124
50
  - lib/bridgetown-seo-tag/image_drop.rb
51
+ - lib/bridgetown-seo-tag/mastodon_drop.rb
125
52
  - lib/bridgetown-seo-tag/url_helper.rb
126
53
  - lib/bridgetown-seo-tag/version.rb
127
54
  - lib/template.html
@@ -138,14 +65,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
138
65
  requirements:
139
66
  - - ">="
140
67
  - !ruby/object:Gem::Version
141
- version: 2.7.0
68
+ version: 3.1.0
142
69
  required_rubygems_version: !ruby/object:Gem::Requirement
143
70
  requirements:
144
71
  - - ">="
145
72
  - !ruby/object:Gem::Version
146
73
  version: '0'
147
74
  requirements: []
148
- rubygems_version: 3.3.3
75
+ rubygems_version: 3.3.26
149
76
  signing_key:
150
77
  specification_version: 4
151
78
  summary: A Bridgetown plugin to add metadata tags for search engines and social networks