bridgetown-seo-tag 3.0.2 → 4.0.0

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: 9a69aa5dfea8921df56935c8a5c109ac28e07beb3f7c222efc6b08768423b82b
4
- data.tar.gz: ec35cb8554ca7f02dff2d10bde9a2e9dc92dbed657e19e022ba550be8124d159
3
+ metadata.gz: ff4c1b2db4c7aff61742d23ffcf023f2bd52092952e3b6c0d3af2a49e3990b2f
4
+ data.tar.gz: 7a4cbaa616f17f53c0c5868f3d950cb39e1cd2bcf0cf6d2b90740430ce5a0cc9
5
5
  SHA512:
6
- metadata.gz: 630e8a49854c0b91436fab5ef2a0621a77ec2c1c2d9c7c09918469a464dcbb6af3860107aad10bf7ebf33b1d3f91bf560bb50acd12d47f8b59d8f060b015574a
7
- data.tar.gz: 18185c1b8d4e8d6f690927c2df7238ec450aca247b405d953eac5032352388040fe054f37ae69274cea7d9e21254cd0c9164aa1985f17b414475eec127d6baa3
6
+ metadata.gz: 4bfa79c801ea61b5a66d8200b890e55090db444824cc9a2be37eafc3f07f798a5d1786109027cd33946ca4891649a8a4684bec7215f3f99b2c249dadedbf32e1
7
+ data.tar.gz: f64e6d25f016aec3e687ee38f9d6f9d88dc59027b5bb1bfff6ee595703c7f65413ebffe6ff1693b85ad1fafeb126b99b69d33af393a9ff5518f058b87f50ed5b
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
 
@@ -14,6 +14,6 @@ Layout/LineLength:
14
14
  - spec/**/*
15
15
  - bridgetown-seo-tag.gemspec
16
16
 
17
- Layout/BlockLength:
17
+ Metrics/BlockLength:
18
18
  Exclude:
19
19
  - spec/**/*
data/CHANGELOG.md ADDED
@@ -0,0 +1,27 @@
1
+ # master
2
+
3
+ ## 4.0.0 / 2021-04-17
4
+
5
+ * New release with helper to support Ruby templates like ERB
6
+
7
+ ## 3.0.5 / 2020-06-18
8
+
9
+ * Final release
10
+
11
+ ## 3.0.5.beta1 / 2020-05-31
12
+
13
+ * Fix bugs due to Bridgetown 0.15 switch to `render` tag.
14
+ * Switch to using Rubocop Bridgetown gem.
15
+
16
+ ## 3.0.4 / 2020-05-01
17
+
18
+ Update to require a minimum Ruby version of 2.5.
19
+
20
+ ## 3.0.3 / 2020-04-19
21
+
22
+ Allow `site.metadata.twitter` data if present. Look for `page.subtitle` if
23
+ `page.description` isn't present.
24
+
25
+ ## 3.0.0 / 2020-04-14
26
+
27
+ Use Bridgetown gem and rename to bridgetown-seo-tag.
data/README.md CHANGED
@@ -4,31 +4,137 @@ 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
- ## What it does
7
+ ## Installation
8
+
9
+ Run this command to add this plugin to your site's Gemfile:
10
+
11
+ ```shell
12
+ $ bundle add bridgetown-seo-tag -g bridgetown_plugins
13
+ ```
14
+
15
+ Or simply add this line to your Gemfile:
16
+
17
+ ```ruby
18
+ gem 'bridgetown-seo-tag', group: "bridgetown_plugins"
19
+ ```
20
+
21
+ And then add the Liquid tag to your HTML head:
22
+
23
+ ```liquid
24
+ {% seo %}
25
+ ```
26
+
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
8
42
 
9
43
  Bridgetown SEO Tag adds the following meta tags to your site:
10
44
 
11
- * Page title, with site title or description appended
45
+ * Page title, with site title or description appended (optional)
12
46
  * Page description
13
47
  * Canonical URL
14
48
  * Next and previous URLs on paginated pages
15
49
  * [Open Graph](https://ogp.me/) title, description, site title, and URL (for Facebook, LinkedIn, etc.)
16
- * [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
17
51
 
18
52
  While you could theoretically add the necessary metadata tags yourself, Bridgetown SEO Tag provides a battle-tested template of crowdsourced best-practices.
19
53
 
20
54
  **NOTE:** make sure you add your site-wide SEO Tag metadata to `src/_data/site_metadata.yml`, not `bridgetown.config.yml`
21
55
 
22
- ## 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:
75
+
76
+ ```yml
77
+ twitter:
78
+ username: benbalter
79
+ card: summary
80
+ ```
81
+
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.
23
121
 
24
- Bridgetown SEO tag is designed to output machine-readable metadata for search engines and social networks to index and display.
122
+ Here is a very basic example, that you are encouraged to adapt to your needs:
25
123
 
26
- 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.
124
+ ```yml
125
+ defaults:
126
+ - scope:
127
+ path: ""
128
+ values:
129
+ image: /assets/images/default-card.png
130
+ ```
27
131
 
28
- ## Documentation
132
+ [More advanced usage information is on the Wiki here.](https://github.com/bridgetownrb/bridgetown-seo-tag/wiki/Advanced-Usage)
29
133
 
30
- More detailed documentation forthcoming.
134
+ ## Testing
31
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
32
138
 
33
139
  ## Contributing
34
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,18 +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
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r!^(test|spec|features)/!) }
17
- spec.bindir = "exe"
18
- spec.executables = spec.files.grep(%r!^exe/!) { |f| File.basename(f) }
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r!^(test|script|spec|features)/!) }
19
17
  spec.require_paths = ["lib"]
20
18
 
21
- spec.add_dependency "bridgetown", ">= 0.6", "< 2.0"
19
+ spec.add_dependency "bridgetown", ">= 0.20.0", "< 2.0"
22
20
 
23
21
  spec.add_development_dependency "bundler", ">= 1.15"
24
22
  spec.add_development_dependency "html-proofer", "~> 3.7"
25
23
  spec.add_development_dependency "rake", "~> 12.0"
26
24
  spec.add_development_dependency "rspec", "~> 3.5"
27
- spec.add_development_dependency "rubocop-jekyll", "~> 0.5"
25
+ spec.add_development_dependency "rubocop-bridgetown", "~> 0.2"
28
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
@@ -89,19 +89,21 @@ module Bridgetown
89
89
 
90
90
  def description
91
91
  @description ||= begin
92
- format_string(page["description"] || page["excerpt"]) || site_description
92
+ format_string(
93
+ page["description"] || page["subtitle"] || page["excerpt"]
94
+ ) || site_description
93
95
  end
94
96
  end
95
97
 
96
98
  # A drop representing the page author
97
99
  def author
98
- @author ||= AuthorDrop.new(:page => page, :site => site)
100
+ @author ||= AuthorDrop.new(page: page, site: site)
99
101
  end
100
102
 
101
103
  # Returns a Drop representing the page's image
102
104
  # Returns nil if the image has no path, to preserve backwards compatability
103
105
  def image
104
- @image ||= ImageDrop.new(:page => page, :context => @context)
106
+ @image ||= ImageDrop.new(page: page, context: @context)
105
107
  @image if @image.path
106
108
  end
107
109
 
@@ -197,7 +199,7 @@ module Bridgetown
197
199
  total = @context["paginator"]["total_pages"]
198
200
  paginator_message = site["seo_paginator_message"] || "Page %<current>s of %<total>s for "
199
201
 
200
- format(paginator_message, :current => current, :total => total) if current > 1
202
+ format(paginator_message, current: current, total: total) if current > 1
201
203
  end
202
204
 
203
205
  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.2"
8
+ VERSION = "4.0.0"
9
9
  end
10
10
  end
data/lib/template.html CHANGED
@@ -62,7 +62,7 @@
62
62
  {% endif %}
63
63
 
64
64
  {% if site.metadata.twitter %}
65
- <meta name="twitter:site" content="@{{ site.metadata.twitter.username | remove:'@' }}" />
65
+ <meta name="twitter:site" content="@{{ site.metadata.twitter.username | default: site.metadata.twitter | remove:'@' }}" />
66
66
 
67
67
  {% if seo_tag.author.twitter %}
68
68
  <meta name="twitter:creator" content="@{{ seo_tag.author.twitter | remove:'@' }}" />
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.2
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bridgetown Team
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-14 00:00:00.000000000 Z
11
+ date: 2021-04-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.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,25 +110,21 @@ files:
110
110
  - ".rspec"
111
111
  - ".rubocop.yml"
112
112
  - ".rubocop_todo.yml"
113
+ - CHANGELOG.md
113
114
  - Gemfile
114
- - History.markdown
115
115
  - LICENSE.txt
116
116
  - README.md
117
117
  - Rakefile
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
124
125
  - lib/bridgetown-seo-tag/url_helper.rb
125
126
  - lib/bridgetown-seo-tag/version.rb
126
127
  - lib/template.html
127
- - script/bootstrap
128
- - script/cibuild
129
- - script/fmt
130
- - script/release
131
- - script/test
132
128
  homepage: https://github.com/bridgetownrb/bridgetown-seo-tag
133
129
  licenses:
134
130
  - MIT
@@ -141,14 +137,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
141
137
  requirements:
142
138
  - - ">="
143
139
  - !ruby/object:Gem::Version
144
- version: 2.4.0
140
+ version: 2.5.0
145
141
  required_rubygems_version: !ruby/object:Gem::Requirement
146
142
  requirements:
147
143
  - - ">="
148
144
  - !ruby/object:Gem::Version
149
145
  version: '0'
150
146
  requirements: []
151
- rubygems_version: 3.0.6
147
+ rubygems_version: 3.1.2
152
148
  signing_key:
153
149
  specification_version: 4
154
150
  summary: A Bridgetown plugin to add metadata tags for search engines and social networks
data/History.markdown DELETED
@@ -1,5 +0,0 @@
1
- # Change Log
2
-
3
- ## 3.0.0 / 2020-04-14
4
-
5
- Use Bridgetown gem and rename to bridgetown-seo-tag.
data/script/bootstrap DELETED
@@ -1,5 +0,0 @@
1
- #!/bin/sh
2
-
3
- set -ex
4
-
5
- bundle install
data/script/cibuild DELETED
@@ -1,6 +0,0 @@
1
- #!/bin/sh
2
-
3
- set -ex
4
-
5
- script/fmt
6
- script/test
data/script/fmt DELETED
@@ -1,10 +0,0 @@
1
- #!/bin/bash
2
- set -e
3
-
4
- echo "Rubocop $(bundle exec rubocop --version)"
5
- bundle exec rubocop -D -E $@
6
- success=$?
7
- if ((success != 0)); then
8
- echo -e "\nTry running \`script/fmt -a\` to automatically fix errors"
9
- fi
10
- exit $success
data/script/release DELETED
@@ -1,7 +0,0 @@
1
- #!/bin/sh
2
- # Tag and push a release.
3
-
4
- set -e
5
-
6
- script/cibuild
7
- bundle exec rake release
data/script/test DELETED
@@ -1,4 +0,0 @@
1
- #!/bin/bash
2
- set -ex
3
-
4
- bundle exec rspec "$@"