bridgetown-seo-tag 3.0.5.beta1 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +7 -0
- data/CHANGELOG.md +24 -6
- data/README.md +8 -0
- data/bridgetown-seo-tag.gemspec +2 -2
- data/lib/bridgetown-seo-tag/author_drop.rb +12 -15
- data/lib/bridgetown-seo-tag/builder.rb +19 -0
- data/lib/bridgetown-seo-tag/drop.rb +49 -52
- data/lib/bridgetown-seo-tag/image_drop.rb +5 -7
- data/lib/bridgetown-seo-tag/version.rb +2 -2
- data/lib/bridgetown-seo-tag.rb +4 -6
- metadata +10 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 700724012209f996a9aafe12a6fea52c050e39e0f6afba904e6ea41c5205f6dd
|
4
|
+
data.tar.gz: 383ad71d2b5dd8923f40bc8c5e01d7f437ebbce97b3c80d0c84847c2c1895d8a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31d8e25501780ce3b73f9b8d9abfff7efa8ddfe1b0f547627742d606458483f454e029b30c1c2cf7cea1040633f347f569198cfdd40dcafd516e3ba0c999395c
|
7
|
+
data.tar.gz: cdf16c8875a8b632cc59707fa251a1428f8b64e51871eac6db143615b681f98d8b935e8749edd1d41f02e15dd36bd8c830682d3114890b00b55bbdc1da0fb5c9
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,19 +1,37 @@
|
|
1
|
-
#
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## 5.0.0 / 2021-10-17
|
4
|
+
|
5
|
+
- Change "Site Title | Site Tagline" format to "Site Title: Site Tagline"
|
6
|
+
- also handle Bridgetown 1.0 templates where the homepage title defaults to `Index`
|
7
|
+
- upgrade rubocop-bridgetown gem to 0.3
|
8
|
+
|
9
|
+
## 4.0.1 / 2021-06-04
|
10
|
+
|
11
|
+
- Fix bug where resources' relative URLs weren't included properly
|
12
|
+
|
13
|
+
## 4.0.0 / 2021-04-17
|
14
|
+
|
15
|
+
- New release with helper to support Ruby templates like ERB
|
16
|
+
|
17
|
+
## 3.0.5 / 2020-06-18
|
18
|
+
|
19
|
+
- Final release
|
2
20
|
|
3
21
|
## 3.0.5.beta1 / 2020-05-31
|
4
22
|
|
5
|
-
|
6
|
-
|
23
|
+
- Fix bugs due to Bridgetown 0.15 switch to `render` tag.
|
24
|
+
- Switch to using Rubocop Bridgetown gem.
|
7
25
|
|
8
26
|
## 3.0.4 / 2020-05-01
|
9
27
|
|
10
|
-
Update to require a minimum Ruby version of 2.5.
|
28
|
+
- Update to require a minimum Ruby version of 2.5.
|
11
29
|
|
12
30
|
## 3.0.3 / 2020-04-19
|
13
31
|
|
14
|
-
Allow `site.metadata.twitter` data if present. Look for `page.subtitle` if
|
32
|
+
- Allow `site.metadata.twitter` data if present. Look for `page.subtitle` if
|
15
33
|
`page.description` isn't present.
|
16
34
|
|
17
35
|
## 3.0.0 / 2020-04-14
|
18
36
|
|
19
|
-
Use Bridgetown gem and rename to bridgetown-seo-tag.
|
37
|
+
- Use Bridgetown gem and rename to bridgetown-seo-tag.
|
data/README.md
CHANGED
@@ -30,6 +30,14 @@ Or if you wish to control your HTML `<title>` tag yourself:
|
|
30
30
|
{% seo title=false %}
|
31
31
|
```
|
32
32
|
|
33
|
+
You can use the `seo` helper in Ruby templates as well:
|
34
|
+
|
35
|
+
```erb
|
36
|
+
<%= seo %>
|
37
|
+
<!-- or -->
|
38
|
+
<%= seo title: false %>
|
39
|
+
```
|
40
|
+
|
33
41
|
## Summary
|
34
42
|
|
35
43
|
Bridgetown SEO Tag adds the following meta tags to your site:
|
data/bridgetown-seo-tag.gemspec
CHANGED
@@ -16,11 +16,11 @@ Gem::Specification.new do |spec|
|
|
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", ">= 0.
|
19
|
+
spec.add_dependency "bridgetown", ">= 0.20.0", "< 2.0"
|
20
20
|
|
21
21
|
spec.add_development_dependency "bundler", ">= 1.15"
|
22
22
|
spec.add_development_dependency "html-proofer", "~> 3.7"
|
23
23
|
spec.add_development_dependency "rake", "~> 12.0"
|
24
24
|
spec.add_development_dependency "rspec", "~> 3.5"
|
25
|
-
spec.add_development_dependency "rubocop-bridgetown", "~> 0.
|
25
|
+
spec.add_development_dependency "rubocop-bridgetown", "~> 0.3"
|
26
26
|
end
|
@@ -41,8 +41,7 @@ module Bridgetown
|
|
41
41
|
|
42
42
|
private
|
43
43
|
|
44
|
-
attr_reader :page
|
45
|
-
attr_reader :site
|
44
|
+
attr_reader :page, :site
|
46
45
|
|
47
46
|
# Finds the page author in the page.author, page.authors, or site.author
|
48
47
|
#
|
@@ -62,10 +61,9 @@ module Bridgetown
|
|
62
61
|
# Returns a hash representing additional metadata or an empty hash
|
63
62
|
def site_data_hash
|
64
63
|
@site_data_hash ||= begin
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
author_hash = site.data["authors"][resolved_author]
|
64
|
+
author_hash = if site.data.authors.is_a?(Hash) && resolved_author.is_a?(String)
|
65
|
+
site.data.authors[resolved_author]
|
66
|
+
end
|
69
67
|
author_hash.is_a?(Hash) ? author_hash : {}
|
70
68
|
end
|
71
69
|
end
|
@@ -74,15 +72,14 @@ module Bridgetown
|
|
74
72
|
# including site-wide metadata if the author is provided as a string,
|
75
73
|
# or an empty hash, if the author cannot be resolved
|
76
74
|
def author_hash
|
77
|
-
@author_hash ||=
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
end
|
75
|
+
@author_hash ||= case resolved_author
|
76
|
+
when Hash
|
77
|
+
resolved_author
|
78
|
+
when String
|
79
|
+
{ "name" => resolved_author }.merge(site_data_hash)
|
80
|
+
else
|
81
|
+
{}
|
82
|
+
end
|
86
83
|
end
|
87
84
|
|
88
85
|
# Since author_hash is aliased to fallback_data, any values in the hash
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bridgetown
|
4
|
+
class SeoTag
|
5
|
+
class Builder < Bridgetown::Builder
|
6
|
+
def build
|
7
|
+
helper "seo", helpers_scope: true do |title: true|
|
8
|
+
context = Liquid::Context.new({}, {}, { site: site, page: view.page })
|
9
|
+
tag_output = Liquid::Template.parse(
|
10
|
+
"{% seo #{"title=false" unless title} %}"
|
11
|
+
).render!(context, {})
|
12
|
+
tag_output.respond_to?(:html_safe) ? tag_output.html_safe : tag_output
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
Bridgetown::SeoTag::Builder.register
|
@@ -6,6 +6,7 @@ module Bridgetown
|
|
6
6
|
include Bridgetown::SeoTag::UrlHelper
|
7
7
|
|
8
8
|
TITLE_SEPARATOR = " | "
|
9
|
+
TAGLINE_SEPARATOR = ": "
|
9
10
|
FORMAT_STRING_METHODS = [
|
10
11
|
:markdownify, :strip_html, :normalize_whitespace, :escape_once,
|
11
12
|
].freeze
|
@@ -47,7 +48,14 @@ module Bridgetown
|
|
47
48
|
|
48
49
|
# Page title without site title or description appended
|
49
50
|
def page_title
|
50
|
-
@page_title ||= format_string(
|
51
|
+
@page_title ||= format_string(
|
52
|
+
if (page["title"] == "Index" || page["title"].blank?) &&
|
53
|
+
site_tagline_or_description
|
54
|
+
"#{site_title}#{TAGLINE_SEPARATOR}#{site_tagline_or_description}"
|
55
|
+
else
|
56
|
+
page["title"]
|
57
|
+
end
|
58
|
+
) || site_title
|
51
59
|
end
|
52
60
|
|
53
61
|
def site_tagline_or_description
|
@@ -55,23 +63,18 @@ module Bridgetown
|
|
55
63
|
end
|
56
64
|
|
57
65
|
# Page title with site title or description appended
|
58
|
-
# rubocop:disable Metrics/CyclomaticComplexity
|
59
66
|
def title
|
60
|
-
@title ||=
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
page_title || site_title
|
67
|
-
end
|
68
|
-
end
|
67
|
+
@title ||= if site_title && page_title != site_title &&
|
68
|
+
!format_string(page_title).start_with?(site_title + TAGLINE_SEPARATOR)
|
69
|
+
page_title + TITLE_SEPARATOR + site_title
|
70
|
+
else
|
71
|
+
page_title || site_title
|
72
|
+
end
|
69
73
|
|
70
74
|
return page_number + @title if page_number
|
71
75
|
|
72
76
|
@title
|
73
77
|
end
|
74
|
-
# rubocop:enable Metrics/CyclomaticComplexity
|
75
78
|
|
76
79
|
def name
|
77
80
|
return @name if defined?(@name)
|
@@ -88,11 +91,9 @@ module Bridgetown
|
|
88
91
|
end
|
89
92
|
|
90
93
|
def description
|
91
|
-
@description ||=
|
92
|
-
|
93
|
-
|
94
|
-
) || site_description
|
95
|
-
end
|
94
|
+
@description ||= format_string(
|
95
|
+
page["description"] || page["subtitle"] || page["excerpt"]
|
96
|
+
) || site_description
|
96
97
|
end
|
97
98
|
|
98
99
|
# A drop representing the page author
|
@@ -125,39 +126,33 @@ module Bridgetown
|
|
125
126
|
end
|
126
127
|
|
127
128
|
def type
|
128
|
-
@type ||=
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
end
|
138
|
-
end
|
129
|
+
@type ||= if page_seo["type"]
|
130
|
+
page_seo["type"]
|
131
|
+
elsif homepage_or_about?
|
132
|
+
"WebSite"
|
133
|
+
elsif page["date"]
|
134
|
+
"BlogPosting"
|
135
|
+
else
|
136
|
+
"WebPage"
|
137
|
+
end
|
139
138
|
end
|
140
139
|
|
141
140
|
def links
|
142
|
-
@links ||=
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
end
|
148
|
-
end
|
141
|
+
@links ||= if page_seo["links"]
|
142
|
+
page_seo["links"]
|
143
|
+
elsif homepage_or_about? && site_social["links"]
|
144
|
+
site_social["links"]
|
145
|
+
end
|
149
146
|
end
|
150
147
|
|
151
148
|
def logo
|
152
|
-
@logo ||=
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
end
|
160
|
-
end
|
149
|
+
@logo ||= if !site.data.dig("site_metadata", "logo")
|
150
|
+
nil
|
151
|
+
elsif absolute_url? site.data.dig("site_metadata", "logo")
|
152
|
+
filters.uri_escape site.data.dig("site_metadata", "logo")
|
153
|
+
else
|
154
|
+
filters.uri_escape filters.absolute_url site.data.dig("site_metadata", "logo")
|
155
|
+
end
|
161
156
|
end
|
162
157
|
|
163
158
|
def page_lang
|
@@ -165,13 +160,15 @@ module Bridgetown
|
|
165
160
|
end
|
166
161
|
|
167
162
|
def canonical_url
|
168
|
-
@canonical_url ||=
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
163
|
+
@canonical_url ||= if page["canonical_url"].to_s.present?
|
164
|
+
page["canonical_url"]
|
165
|
+
elsif page["url"].to_s.present?
|
166
|
+
filters.absolute_url(page["url"]).to_s.gsub(%r!/index\.html$!, "/")
|
167
|
+
else
|
168
|
+
filters.absolute_url(page["relative_url"]).to_s.gsub(
|
169
|
+
%r!/index\.html$!, "/"
|
170
|
+
)
|
171
|
+
end
|
175
172
|
end
|
176
173
|
|
177
174
|
private
|
@@ -225,7 +222,7 @@ module Bridgetown
|
|
225
222
|
end
|
226
223
|
|
227
224
|
def site_social
|
228
|
-
@site_social ||= sub_hash(site.data
|
225
|
+
@site_social ||= sub_hash(site.data["site_metadata"], "social")
|
229
226
|
end
|
230
227
|
|
231
228
|
# Safely returns a sub hash
|
@@ -34,14 +34,14 @@ module Bridgetown
|
|
34
34
|
|
35
35
|
private
|
36
36
|
|
37
|
-
attr_accessor :page
|
38
|
-
attr_accessor :context
|
37
|
+
attr_accessor :page, :context
|
39
38
|
|
40
39
|
# The normalized image hash with a `path` key (which may be nil)
|
41
40
|
def image_hash
|
42
|
-
@image_hash ||=
|
41
|
+
@image_hash ||= case page["image"]
|
42
|
+
when Hash
|
43
43
|
{ "path" => nil }.merge(page["image"])
|
44
|
-
|
44
|
+
when String
|
45
45
|
{ "path" => page["image"] }
|
46
46
|
else
|
47
47
|
{ "path" => nil }
|
@@ -50,9 +50,7 @@ module Bridgetown
|
|
50
50
|
alias_method :fallback_data, :image_hash
|
51
51
|
|
52
52
|
def raw_path
|
53
|
-
@raw_path ||=
|
54
|
-
image_hash["path"] || image_hash["facebook"] || image_hash["twitter"]
|
55
|
-
end
|
53
|
+
@raw_path ||= image_hash["path"] || image_hash["facebook"] || image_hash["twitter"]
|
56
54
|
end
|
57
55
|
|
58
56
|
def absolute_url
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Prevent bundler errors
|
4
|
-
module Liquid; class Tag; end; end
|
4
|
+
module Liquid; class Tag; end; end # rubocop:disable Lint/EmptyClass
|
5
5
|
|
6
6
|
module Bridgetown
|
7
7
|
class SeoTag < Liquid::Tag
|
8
|
-
VERSION = "
|
8
|
+
VERSION = "5.0.0"
|
9
9
|
end
|
10
10
|
end
|
data/lib/bridgetown-seo-tag.rb
CHANGED
@@ -81,18 +81,16 @@ module Bridgetown
|
|
81
81
|
private
|
82
82
|
|
83
83
|
def template_contents
|
84
|
-
@template_contents ||=
|
85
|
-
File.read(template_path).gsub(MINIFY_REGEX, "")
|
86
|
-
end
|
84
|
+
@template_contents ||= File.read(template_path).gsub(MINIFY_REGEX, "")
|
87
85
|
end
|
88
86
|
|
89
87
|
def template_path
|
90
|
-
@template_path ||=
|
91
|
-
File.expand_path "./template.html", File.dirname(__FILE__)
|
92
|
-
end
|
88
|
+
@template_path ||= File.expand_path "./template.html", File.dirname(__FILE__)
|
93
89
|
end
|
94
90
|
end
|
95
91
|
end
|
96
92
|
end
|
97
93
|
|
98
94
|
Liquid::Template.register_tag("seo", Bridgetown::SeoTag)
|
95
|
+
|
96
|
+
require "bridgetown-seo-tag/builder"
|
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:
|
4
|
+
version: 5.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:
|
11
|
+
date: 2021-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bridgetown
|
@@ -16,7 +16,7 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.20.0
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: '2.0'
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0.
|
29
|
+
version: 0.20.0
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '2.0'
|
@@ -92,14 +92,14 @@ dependencies:
|
|
92
92
|
requirements:
|
93
93
|
- - "~>"
|
94
94
|
- !ruby/object:Gem::Version
|
95
|
-
version: '0.
|
95
|
+
version: '0.3'
|
96
96
|
type: :development
|
97
97
|
prerelease: false
|
98
98
|
version_requirements: !ruby/object:Gem::Requirement
|
99
99
|
requirements:
|
100
100
|
- - "~>"
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
version: '0.
|
102
|
+
version: '0.3'
|
103
103
|
description:
|
104
104
|
email: maintainers@bridgetownrb.com
|
105
105
|
executables: []
|
@@ -118,6 +118,7 @@ files:
|
|
118
118
|
- bridgetown-seo-tag.gemspec
|
119
119
|
- lib/bridgetown-seo-tag.rb
|
120
120
|
- lib/bridgetown-seo-tag/author_drop.rb
|
121
|
+
- lib/bridgetown-seo-tag/builder.rb
|
121
122
|
- lib/bridgetown-seo-tag/drop.rb
|
122
123
|
- lib/bridgetown-seo-tag/filters.rb
|
123
124
|
- lib/bridgetown-seo-tag/image_drop.rb
|
@@ -139,11 +140,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
139
140
|
version: 2.5.0
|
140
141
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
141
142
|
requirements:
|
142
|
-
- - "
|
143
|
+
- - ">="
|
143
144
|
- !ruby/object:Gem::Version
|
144
|
-
version:
|
145
|
+
version: '0'
|
145
146
|
requirements: []
|
146
|
-
rubygems_version: 3.
|
147
|
+
rubygems_version: 3.1.4
|
147
148
|
signing_key:
|
148
149
|
specification_version: 4
|
149
150
|
summary: A Bridgetown plugin to add metadata tags for search engines and social networks
|