bridgetown-seo-tag 3.0.3 → 4.0.1

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: 19e8233a77aad3796aeb8b05d8a675413be603db165753b3c3ce0d83cd20b042
4
- data.tar.gz: 5da4c3c8af5cd303d7a84848600e571d5b21ad97aa8c06f837458db2e74bbec2
3
+ metadata.gz: abb7aa6ad690aea0cc55f5e18a9dd7be9c1461f4b6d7b57977abfc568ae0f09d
4
+ data.tar.gz: 27388ed583fc7d3cce45d5eab085bf87d5a30320192a844a97541bb71fbf28da
5
5
  SHA512:
6
- metadata.gz: 939f24dc652310da83407866d9ea32e1e024acaa745be7889bb2887d68832e7441b5cefd933ed49f3ea0a0c6fbadf9ca665db033399a6fe2751a8159b83dd881
7
- data.tar.gz: b3e987f8caf569e358e68a343832b19447294be8a80b63482b27a6d8156ebeaac098fb2e14ddb02f536ecf9a6a1aecd08526f3a4d0bc636806b04ec2d1fad845
6
+ metadata.gz: faa21316c33fd7e2bf19228dcc848b147b5b40ba03f1d12da9229b9b7f665fd9f0b5279198fa43644a67fe67374d2554d61cdb5def9ee12a5d1ad3b8a2f6d420
7
+ data.tar.gz: e95daef1af9a8447ac7248fc39b6b9246910150995073b4f8b61160cbf60ac07e48fd3cf721be13310e28eb3cb53d4a1624ea323a0e5d191c6221a509b3758b9
data/.gitignore CHANGED
@@ -7,3 +7,4 @@ spec/reports/
7
7
  spec/fixtures/.bridgetown-cache
8
8
  tmp/
9
9
  vendor/bundle
10
+ .ruby-version
data/.rubocop.yml CHANGED
@@ -1,11 +1,11 @@
1
1
  inherit_from: .rubocop_todo.yml
2
2
 
3
- require: rubocop-jekyll
3
+ require: rubocop-bridgetown
4
4
  inherit_gem:
5
- rubocop-jekyll: .rubocop.yml
5
+ rubocop-bridgetown: .rubocop.yml
6
6
 
7
7
  AllCops:
8
- TargetRubyVersion: 2.4
8
+ TargetRubyVersion: 2.5
9
9
  Exclude:
10
10
  - vendor/**/*
11
11
 
data/CHANGELOG.md ADDED
@@ -0,0 +1,31 @@
1
+ # Changelog
2
+
3
+ ## 4.0.1 / 2021-06-04
4
+
5
+ * Fix bug where resources' relative URLs weren't included properly
6
+
7
+ ## 4.0.0 / 2021-04-17
8
+
9
+ * New release with helper to support Ruby templates like ERB
10
+
11
+ ## 3.0.5 / 2020-06-18
12
+
13
+ * Final release
14
+
15
+ ## 3.0.5.beta1 / 2020-05-31
16
+
17
+ * Fix bugs due to Bridgetown 0.15 switch to `render` tag.
18
+ * Switch to using Rubocop Bridgetown gem.
19
+
20
+ ## 3.0.4 / 2020-05-01
21
+
22
+ Update to require a minimum Ruby version of 2.5.
23
+
24
+ ## 3.0.3 / 2020-04-19
25
+
26
+ Allow `site.metadata.twitter` data if present. Look for `page.subtitle` if
27
+ `page.description` isn't present.
28
+
29
+ ## 3.0.0 / 2020-04-14
30
+
31
+ Use Bridgetown gem and rename to bridgetown-seo-tag.
data/README.md CHANGED
@@ -24,31 +24,117 @@ And then add the Liquid tag to your HTML head:
24
24
  {% seo %}
25
25
  ```
26
26
 
27
- ## What it does
27
+ Or if you wish to control your HTML `<title>` tag yourself:
28
+
29
+ ```liquid
30
+ {% seo title=false %}
31
+ ```
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
+
41
+ ## Summary
28
42
 
29
43
  Bridgetown SEO Tag adds the following meta tags to your site:
30
44
 
31
- * Page title, with site title or description appended
45
+ * Page title, with site title or description appended (optional)
32
46
  * Page description
33
47
  * Canonical URL
34
48
  * Next and previous URLs on paginated pages
35
49
  * [Open Graph](https://ogp.me/) title, description, site title, and URL (for Facebook, LinkedIn, etc.)
36
- * [Twitter Summary Card](https://dev.twitter.com/cards/overview) metadata
50
+ * [Twitter Summary Card](https://developer.twitter.com/en/docs/tweets/optimize-with-cards/guides/getting-started) metadata
37
51
 
38
52
  While you could theoretically add the necessary metadata tags yourself, Bridgetown SEO Tag provides a battle-tested template of crowdsourced best-practices.
39
53
 
40
54
  **NOTE:** make sure you add your site-wide SEO Tag metadata to `src/_data/site_metadata.yml`, not `bridgetown.config.yml`
41
55
 
42
- ## What it doesn't do
56
+ ## Usage
57
+
58
+ The SEO tag will use the following configuration options from `bridgetown.config.yml`:
59
+
60
+ * `url` - The full URL to your site.
61
+ * `lang` - The locale for the site, or the current document if specified in the document's front matter. Format `language_TERRITORY` — default is `en_US`.
62
+
63
+ The SEO tag will respect any of the following if included in your site's `site_metadata.yml` (and simply not include them if they're not defined):
64
+
65
+ * `title` - Your website's title (e.g., Super-cool Website).
66
+ * `tagline` - A short description (e.g., A blog dedicated to reviewing cat gifs), used in instances (like a home page) where there isn't a dedicated document title.
67
+ * `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
+ * `author` - global author information (see [Advanced usage](https://github.com/bridgetownrb/bridgetown-seo-tag/wiki/Advanced-Usage#author-information))
69
+
70
+ * `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
+ * `twitter:card` - The site's default card type
72
+ * `twitter:username` - The site's Twitter handle
73
+
74
+ Example:
43
75
 
44
- Bridgetown SEO tag is designed to output machine-readable metadata for search engines and social networks to index and display.
76
+ ```yml
77
+ twitter:
78
+ username: benbalter
79
+ card: summary
80
+ ```
45
81
 
46
- Bridgetown SEO tag isn't designed to accommodate every possible use case. It should work for most site out of the box and without a laundry list of configuration options that serve only to confuse most users.
82
+ * `facebook` - The following properties are available:
83
+ * `facebook:app_id` - a Facebook app ID for Facebook insights
84
+ * `facebook:publisher` - a Facebook page URL or ID of the publishing entity
85
+ * `facebook:admins` - a Facebook user ID for domain insights linked to a personal account
86
+
87
+ You'll want to describe one or more like so:
88
+
89
+ ```yml
90
+ facebook:
91
+ app_id: 1234
92
+ publisher: 1234
93
+ admins: 1234
94
+ ```
95
+
96
+ * `google_site_verification` for verifying ownership for Google Search Console
97
+ * Alternatively, verify ownership with several services at once using the following format:
98
+
99
+ ```yml
100
+ webmaster_verifications:
101
+ google: 1234
102
+ bing: 1234
103
+ alexa: 1234
104
+ yandex: 1234
105
+ baidu: 1234
106
+ ```
107
+
108
+ The SEO tag will respect the following YAML front matter if included in a post, page, or document:
109
+
110
+ * `title` - The title of the document
111
+ * `description` - A short description of the document's content
112
+ * `image` - URL to an image associated with the document (e.g., `/assets/page-pic.jpg`)
113
+ * `author` - Document-specific author information (see [Advanced usage](https://github.com/bridgetownrb/bridgetown-seo-tag/wiki/Advanced-Usage#author-information))
114
+ * `lang` - Document-specific language information
115
+
116
+ *Note:* Front matter defaults can be used for any of the above values.
117
+
118
+ ### Setting a default image
119
+
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.
121
+
122
+ Here is a very basic example, that you are encouraged to adapt to your needs:
123
+
124
+ ```yml
125
+ defaults:
126
+ - scope:
127
+ path: ""
128
+ values:
129
+ image: /assets/images/default-card.png
130
+ ```
47
131
 
48
- ## Documentation
132
+ [More advanced usage information is on the Wiki here.](https://github.com/bridgetownrb/bridgetown-seo-tag/wiki/Advanced-Usage)
49
133
 
50
- More detailed documentation forthcoming.
134
+ ## Testing
51
135
 
136
+ * Run `bundle exec rspec` to run the test suite
137
+ * Or run `script/cibuild` to validate with Rubocop and test with rspec together
52
138
 
53
139
  ## Contributing
54
140
 
data/Rakefile CHANGED
@@ -5,4 +5,4 @@ require "rspec/core/rake_task"
5
5
 
6
6
  RSpec::Core::RakeTask.new(:spec)
7
7
 
8
- task :default => :spec
8
+ task default: :spec
@@ -11,16 +11,16 @@ 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.4.0"
14
+ spec.required_ruby_version = ">= 2.5.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", ">= 0.6", "< 2.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-jekyll", "~> 0.5"
25
+ spec.add_development_dependency "rubocop-bridgetown", "~> 0.2"
26
26
  end
@@ -44,27 +44,32 @@ module Bridgetown
44
44
  end
45
45
 
46
46
  def payload
47
+ paginator = context.registers[:page].pager if context.registers[:page].respond_to?(:pager)
48
+
47
49
  # site_payload is an instance of UnifiedPayloadDrop
48
50
  Bridgetown::Utils.deep_merge_hashes(
49
51
  context.registers[:site].site_payload,
50
52
  "page" => context.registers[:page],
51
- "paginator" => context["paginator"],
53
+ "paginator" => paginator,
52
54
  "seo_tag" => drop
53
55
  )
54
56
  end
55
57
 
56
58
  def drop
57
59
  if context.registers[:site].liquid_renderer.respond_to?(:cache)
58
- Bridgetown::SeoTag::Drop.new(@text, @context)
60
+ Bridgetown::SeoTag::Drop.new(@text, context)
59
61
  else
60
- @drop ||= Bridgetown::SeoTag::Drop.new(@text, @context)
62
+ @drop ||= Bridgetown::SeoTag::Drop.new(@text, context)
61
63
  end
62
64
  end
63
65
 
64
66
  def info
65
67
  {
66
- :registers => context.registers,
67
- :filters => [Bridgetown::Filters],
68
+ registers: {
69
+ site: context.registers[:site],
70
+ page: context.registers[:page],
71
+ },
72
+ filters: [Bridgetown::Filters],
68
73
  }
69
74
  end
70
75
 
@@ -91,3 +96,5 @@ module Bridgetown
91
96
  end
92
97
 
93
98
  Liquid::Template.register_tag("seo", Bridgetown::SeoTag)
99
+
100
+ require "bridgetown-seo-tag/builder"
@@ -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
@@ -97,13 +97,13 @@ module Bridgetown
97
97
 
98
98
  # A drop representing the page author
99
99
  def author
100
- @author ||= AuthorDrop.new(:page => page, :site => site)
100
+ @author ||= AuthorDrop.new(page: page, site: site)
101
101
  end
102
102
 
103
103
  # Returns a Drop representing the page's image
104
104
  # Returns nil if the image has no path, to preserve backwards compatability
105
105
  def image
106
- @image ||= ImageDrop.new(:page => page, :context => @context)
106
+ @image ||= ImageDrop.new(page: page, context: @context)
107
107
  @image if @image.path
108
108
  end
109
109
 
@@ -166,10 +166,12 @@ module Bridgetown
166
166
 
167
167
  def canonical_url
168
168
  @canonical_url ||= begin
169
- if page["canonical_url"].to_s.empty?
169
+ if page["canonical_url"].to_s.present?
170
+ page["canonical_url"]
171
+ elsif page["url"].to_s.present?
170
172
  filters.absolute_url(page["url"]).to_s.gsub(%r!/index\.html$!, "/")
171
173
  else
172
- page["canonical_url"]
174
+ filters.absolute_url(page["relative_url"]).to_s.gsub(%r!/index\.html$!, "/")
173
175
  end
174
176
  end
175
177
  end
@@ -199,7 +201,7 @@ module Bridgetown
199
201
  total = @context["paginator"]["total_pages"]
200
202
  paginator_message = site["seo_paginator_message"] || "Page %<current>s of %<total>s for "
201
203
 
202
- format(paginator_message, :current => current, :total => total) if current > 1
204
+ format(paginator_message, current: current, total: total) if current > 1
203
205
  end
204
206
 
205
207
  attr_reader :context
@@ -5,6 +5,6 @@ module Liquid; class Tag; end; end
5
5
 
6
6
  module Bridgetown
7
7
  class SeoTag < Liquid::Tag
8
- VERSION = "3.0.3"
8
+ VERSION = "4.0.1"
9
9
  end
10
10
  end
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: 3.0.3
4
+ version: 4.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bridgetown Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-19 00:00:00.000000000 Z
11
+ date: 2021-06-04 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.6'
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.6'
29
+ version: 0.20.0
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '2.0'
@@ -87,19 +87,19 @@ dependencies:
87
87
  - !ruby/object:Gem::Version
88
88
  version: '3.5'
89
89
  - !ruby/object:Gem::Dependency
90
- name: rubocop-jekyll
90
+ name: rubocop-bridgetown
91
91
  requirement: !ruby/object:Gem::Requirement
92
92
  requirements:
93
93
  - - "~>"
94
94
  - !ruby/object:Gem::Version
95
- version: '0.5'
95
+ version: '0.2'
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.5'
102
+ version: '0.2'
103
103
  description:
104
104
  email: maintainers@bridgetownrb.com
105
105
  executables: []
@@ -110,15 +110,15 @@ files:
110
110
  - ".rspec"
111
111
  - ".rubocop.yml"
112
112
  - ".rubocop_todo.yml"
113
- - ".ruby-version"
113
+ - CHANGELOG.md
114
114
  - Gemfile
115
- - History.markdown
116
115
  - LICENSE.txt
117
116
  - README.md
118
117
  - Rakefile
119
118
  - bridgetown-seo-tag.gemspec
120
119
  - lib/bridgetown-seo-tag.rb
121
120
  - lib/bridgetown-seo-tag/author_drop.rb
121
+ - lib/bridgetown-seo-tag/builder.rb
122
122
  - lib/bridgetown-seo-tag/drop.rb
123
123
  - lib/bridgetown-seo-tag/filters.rb
124
124
  - lib/bridgetown-seo-tag/image_drop.rb
@@ -137,14 +137,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
137
137
  requirements:
138
138
  - - ">="
139
139
  - !ruby/object:Gem::Version
140
- version: 2.4.0
140
+ version: 2.5.0
141
141
  required_rubygems_version: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - ">="
144
144
  - !ruby/object:Gem::Version
145
145
  version: '0'
146
146
  requirements: []
147
- rubygems_version: 3.0.6
147
+ rubygems_version: 3.1.2
148
148
  signing_key:
149
149
  specification_version: 4
150
150
  summary: A Bridgetown plugin to add metadata tags for search engines and social networks
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- ruby-2.6.4@bridgetown-gems
data/History.markdown DELETED
@@ -1,10 +0,0 @@
1
- # Change Log
2
-
3
- ## 3.0.3 / 2020-04-19
4
-
5
- Allow `site.metadata.twitter` data if present. Look for `page.subtitle` if
6
- `page.description` isn't present.
7
-
8
- ## 3.0.0 / 2020-04-14
9
-
10
- Use Bridgetown gem and rename to bridgetown-seo-tag.