Merge branch 'master' into canonical

This commit is contained in:
Igor Żuk 2020-10-23 10:45:06 +02:00 committed by GitHub
commit 3564225820
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 148 additions and 56 deletions

14
.github/workflows/actions/memprof.rb vendored Normal file
View File

@ -0,0 +1,14 @@
# frozen_string_literal: true
require 'jekyll'
require 'memory_profiler'
MemoryProfiler.report(allow_files: 'lib/jekyll-seo-tag') do
Jekyll::PluginManager.require_from_bundler
Jekyll::Commands::Build.process({
"source" => File.expand_path(ARGV[0]),
"destination" => File.expand_path("#{ARGV[0]}/_site"),
"disable_disk_cache" => true,
})
puts ''
end.pretty_print(scale_bytes: true, normalize_paths: true)

61
.github/workflows/third-party.yml vendored Normal file
View File

@ -0,0 +1,61 @@
name: Third-Party Repository Profiling
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
build_n_profile:
if: "!contains(github.event.commits[0].message, '[ci skip]')"
runs-on: 'ubuntu-latest'
steps:
- name: Checkout Jekyll SEO Tag
uses: actions/checkout@v2
with:
fetch-depth: 5
path: jekyll-seo-tag
- name: Checkout Third-Party Repository (WITHOUT SEO Tag)
uses: actions/checkout@v2
with:
repository: ashmaroli/tomjoht.github.io
ref: 'no-seo-tag'
path: alpha-sandbox
- name: Checkout Same Third-Party Repository (WITH SEO Tag)
uses: actions/checkout@v2
with:
repository: ashmaroli/tomjoht.github.io
ref: 'seo-tag'
path: sandbox
- name: Set up Ruby
uses: actions/setup-ruby@v1
with:
ruby-version: 2.6.x
- name: Set up Dependencies Cache
uses: actions/cache@v1
with:
path: sandbox/vendor/bundle
key: ubuntu-latest-gems-
restore-keys: |
ubuntu-latest-gems-
- name: Set up Dependencies
run: |
gem update --system --no-document
gem update bundler --no-document
bundle config gemfile sandbox/Gemfile
bundle config path vendor/bundle
bundle install --jobs 4 --retry 3
- name: Run Jekyll Build (WITHOUT SEO Tag) 3 times
run: |
bundle exec jekyll build -s alpha-sandbox -d alpha-sandbox/_site --trace
bundle exec jekyll build -s alpha-sandbox -d alpha-sandbox/_site --trace
bundle exec jekyll build -s alpha-sandbox -d alpha-sandbox/_site --trace
- name: Run Jekyll Build (WITH SEO Tag) 3 times
run: |
bundle exec jekyll build -s sandbox -d sandbox/_site --trace
bundle exec jekyll build -s sandbox -d sandbox/_site --trace
bundle exec jekyll build -s sandbox -d sandbox/_site --trace
- name: Memory Analysis of Jekyll Build (WITH SEO Tag)
run: bundle exec ruby jekyll-seo-tag/.github/workflows/actions/memprof.rb sandbox

View File

@ -5,7 +5,7 @@ inherit_gem:
rubocop-jekyll: .rubocop.yml
AllCops:
TargetRubyVersion: 2.3
TargetRubyVersion: 2.4
Exclude:
- vendor/**/*
@ -14,6 +14,6 @@ Layout/LineLength:
- spec/**/*
- jekyll-seo-tag.gemspec
Layout/BlockLength:
Metrics/BlockLength:
Exclude:
- spec/**/*

View File

@ -1,34 +1,46 @@
## HEAD
### Documentation
* HTTPS links to schema.org (#350)
* use example.com for example URL (#351)
* remove Google+ from example snippet (#358)
* HTTPS link to https://ogp.me/ (#359)
* Rename Google webmaster tools to Google Search Console (#403)
* Improve documentation on plugin usage (#399)
* Structured Data Testing Tool is deprecated (#409)
### Minor Enhancements
* Adding possibility to change pagination message by config file (#324)
* Make Twitter Summary Card without having Twitter account (#284)
* Ensure a single leading `@` for twitter usernames (#367)
* Prefer site.tagline to site.description for page title (#356)
* chore(ci): bump Ruby versions (#385)
## 2.7.1 / 2020-10-18
### Development Fixes
* Memoize #author_hash in SeoTag::AuthorDrop (#342)
* chore(ci): test Jekyll v4.0 (#372)
* Fix locale specs that use the fallback locale (#360)
* style: align with latest jekyll-rubocop (#382)
* refactor: mutate site payload instead of duplicating it (#419)
## 2.7.0 / 2020-10-18
### Minor Enhancements
* Change pagination message with `seo_paginator_message` option (#324)
* Make Twitter Summary Card without having Twitter account (#284)
* Prefer site.tagline to site.description for page title (#356)
* Render og:locale meta only when defined explicitly (#388)
### Bug Fixes
* Reduce allocations of instance-agnostic objects (#376)
* Fix Travis builds for Jekyll 3.x (#415)
* Ensure a single leading `@` for twitter usernames (#367)
### Development Fixes
* chore(deps): require Ruby > 2.4.0 EOL
* test: fix locale specs that use the fallback locale (#360)
* refactor: Replace read-only empty hash with private constant (#418)
* refactor: Mutate hash literals instead of duplicating them (#417)
* refactor: Reduce allocations of instance-agnostic objects (#376)
* refactor: Memoize #author_hash in SeoTag::AuthorDrop (#342)
* refactor: simplify conditional in SeoTag::Drop#date_modified (#343)
* chore(ci): profile seo-tag plugin on a third-party repository (#414)
* chore(ci): Jekyll v4.0 (#372)
* chore(ci): test against current stable Ruby 2.5 and 2.7 (#385)
* style: align with latest jekyll-rubocop (#382)
* fix: Travis builds for Jekyll 3.x (#415)
### Documentation
* Structured Data Testing Tool is deprecated (#409)
* Rename Google webmaster tools to Google Search Console (#403)
* Improve documentation on plugin usage (#399)
* remove Google+ from example snippet (#358)
* HTTPS link to https://ogp.me/ (#359)
* HTTPS links to schema.org (#350)
* use example.com for example URL (#351)
## 2.6.1 / 2019-05-17

View File

@ -66,7 +66,8 @@ The following properties are available:
yandex: 1234
baidu: 1234
```
* `lang` - The locale these tags are marked up in. Of the format `language_TERRITORY`. Default is `en_US`.
* `locale` - The locale these tags are marked up in. Of the format `language_TERRITORY`. Default is `en_US`. Takes priority
over existing config key `lang`.
The SEO tag will respect the following YAML front matter if included in a post, page, or document:
@ -74,6 +75,6 @@ The SEO tag will respect the following YAML front matter if included in a post,
* `description` - A short description of the page's content
* `image` - URL to an image associated with the post, page, or document (e.g., `/assets/page-pic.jpg`)
* `author` - Page-, post-, or document-specific author information (see [Advanced usage](advanced-usage.md#author-information))
* `lang` - Page-, post-, or document-specific language information
* `locale` - Page-, post-, or document-specific locale information. Takes priority over existing front matter attribute `lang`.
*Note:* Front matter defaults can be used for any of the above values as described in advanced usage with an image example.

View File

@ -19,14 +19,14 @@ Gem::Specification.new do |spec|
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
end
spec.required_ruby_version = ">= 2.3.0"
spec.required_ruby_version = ">= 2.4.0"
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r!^(test|spec|features)/!) }
spec.bindir = "exe"
spec.executables = spec.files.grep(%r!^exe/!) { |f| File.basename(f) }
spec.require_paths = ["lib"]
spec.add_dependency "jekyll", ">= 3.3", "< 5.0"
spec.add_dependency "jekyll", ">= 3.8", "< 5.0"
spec.add_development_dependency "bundler", ">= 1.15"
spec.add_development_dependency "html-proofer", "~> 3.7"
spec.add_development_dependency "rspec", "~> 3.5"

View File

@ -47,12 +47,11 @@ module Jekyll
def payload
# site_payload is an instance of UnifiedPayloadDrop. See https://git.io/v5ajm
Jekyll::Utils.deep_merge_hashes(
context.registers[:site].site_payload,
"page" => context.registers[:page],
"paginator" => context["paginator"],
"seo_tag" => drop
)
context.registers[:site].site_payload.tap do |site_payload|
site_payload["page"] = context.registers[:page]
site_payload["paginator"] = context["paginator"]
site_payload["seo_tag"] = drop
end
end
def drop

View File

@ -78,7 +78,7 @@ module Jekyll
if resolved_author.is_a? Hash
resolved_author
elsif resolved_author.is_a? String
{ "name" => resolved_author }.merge(site_data_hash)
{ "name" => resolved_author }.merge!(site_data_hash)
else
{}
end

View File

@ -11,8 +11,11 @@ module Jekyll
].freeze
HOMEPAGE_OR_ABOUT_REGEX = %r!^/(about/)?(index.html?)?$!.freeze
EMPTY_READ_ONLY_HASH = {}.freeze
private_constant :EMPTY_READ_ONLY_HASH
def initialize(text, context)
@obj = {}
@obj = EMPTY_READ_ONLY_HASH
@mutations = {}
@text = text
@context = context
@ -109,13 +112,7 @@ module Jekyll
def date_modified
@date_modified ||= begin
date = if page_seo["date_modified"]
page_seo["date_modified"]
elsif page["last_modified_at"]
page["last_modified_at"].to_liquid
else
page["date"]
end
date = page_seo["date_modified"] || page["last_modified_at"].to_liquid || page["date"]
filters.date_to_xmlschema(date) if date
end
end
@ -164,6 +161,10 @@ module Jekyll
@page_lang ||= page["lang"] || site["lang"] || "en_US"
end
def page_locale
@page_locale ||= (page["locale"] || site["locale"] || page_lang).tr("-", "_")
end
def canonical_url
@canonical_url ||= begin
if page["canonical_url"].to_s.empty?
@ -238,7 +239,7 @@ module Jekyll
if hash[key].is_a?(Hash)
hash[key]
else
{}
EMPTY_READ_ONLY_HASH
end
end
end

View File

@ -39,13 +39,17 @@ module Jekyll
# The normalized image hash with a `path` key (which may be nil)
def image_hash
@image_hash ||= if page["image"].is_a?(Hash)
{ "path" => nil }.merge(page["image"])
elsif page["image"].is_a?(String)
{ "path" => page["image"] }
else
{ "path" => nil }
end
@image_hash ||= begin
image_meta = page["image"]
if image_meta.is_a?(Hash)
{ "path" => nil }.merge!(image_meta)
elsif image_meta.is_a?(String)
{ "path" => image_meta }
else
{ "path" => nil }
end
end
end
alias_method :fallback_data, :image_hash

View File

@ -5,6 +5,6 @@ module Liquid; class Tag; end; end
module Jekyll
class SeoTag < Liquid::Tag
VERSION = "2.6.1"
VERSION = "2.7.1"
end
end

View File

@ -13,7 +13,7 @@
<meta name="author" content="{{ seo_tag.author.name }}" />
{% endif %}
<meta property="og:locale" content="{{ seo_tag.page_lang | replace:'-','_' }}" />
<meta property="og:locale" content="{{ seo_tag.page_locale }}" />
{% if seo_tag.description %}
<meta name="description" content="{{ seo_tag.description }}" />