Compare commits
131 Commits
no-cache-d
...
master
Author | SHA1 | Date |
---|---|---|
jekyllbot | f449b1af64 | |
Pierre de La Morinerie | 589feb0186 | |
Ashwin Maroli | db0e639259 | |
Ashwin Maroli | c90dcf86d8 | |
jekyllbot | 6005f93781 | |
Scott Perry | 1980476395 | |
jekyllbot | 7d1d478c0b | |
Amir Masoud Abdol | 799da8f3bf | |
jekyllbot | 62d7e8af8b | |
Baoshuo Ren | 5200f23221 | |
jekyllbot | 9e452bf1d6 | |
Peter Goldstein | b41ebd39a8 | |
Ashwin Maroli | 792a0fa3ab | |
jekyllbot | 7209c422e5 | |
Parker Moore | 54d37a8396 | |
Ashwin Maroli | 8303d31d79 | |
Ashwin Maroli | c658a8dd9d | |
jekyllbot | 4037708eff | |
Tobias | e19993b3e0 | |
jekyllbot | dba6621d1f | |
Tobias | 4a590c9d0b | |
jekyllbot | 41b23937a9 | |
fauno | 062604e7e1 | |
jekyllbot | 36330e876c | |
Igor Żuk | f1b98288e3 | |
jekyllbot | dff018c347 | |
Ilgiz Mustafin | 8b5d2901c2 | |
Ashwin Maroli | be9ce5d13e | |
Ashwin Maroli | b5c53de8f0 | |
jekyllbot | 7c0d75a29b | |
Ashwin Maroli | 6c387eaeb4 | |
Ashwin Maroli | e1a60e2fdf | |
jekyllbot | 7b5478a249 | |
Ashwin Maroli | e3d0542ce6 | |
jekyllbot | 01fcf38c8b | |
Michael Currin | d055720b4e | |
jekyllbot | 93c664bce0 | |
Elias Fröhner | 9cb1ad0bd6 | |
Ashwin Maroli | 22a160cb32 | |
Frank Taillandier | df294bb491 | |
jekyllbot | a7e1b5d8ec | |
Ashwin Maroli | a1e0cdd25f | |
Frank Taillandier | 20d61fa728 | |
Frank Taillandier | 8d509f2616 | |
jekyllbot | 6f30b00845 | |
Ashwin Maroli | 80da6a7da9 | |
jekyllbot | d77ffc4de5 | |
Ashwin Maroli | e1ff8ee6e8 | |
jekyllbot | 442133d898 | |
Ashwin Maroli | 54beeaaaf6 | |
jekyllbot | dac459f6f9 | |
Ashwin Maroli | 76e062d734 | |
jekyllbot | ae0f02f1e0 | |
Ashwin Maroli | c00f3dbc26 | |
jekyllbot | ae6ce57b36 | |
Ashwin Maroli | 6906e8792e | |
jekyllbot | 933b914ab2 | |
Joe Masilotti | 0b5f02ab6c | |
jekyllbot | 8dc3a01b39 | |
Ashwin Maroli | 12c2c8eb64 | |
jekyllbot | fa6ca2891c | |
Pavel Timofeev | 4f38339782 | |
jekyllbot | 6135021410 | |
Ashwin Maroli | b019d441b9 | |
jekyllbot | 47e874a116 | |
Frank Taillandier | cdbc366129 | |
jekyllbot | 38ef0bea22 | |
Frank Taillandier | e22311ec1a | |
Frank Taillandier | 76fd24544c | |
Frank Taillandier | fc51dbdf86 | |
jekyllbot | 0f24641c5e | |
Liam Cooke | 6f35c9c05b | |
jekyllbot | 2d058584e4 | |
Frank Taillandier | d8a80bfba4 | |
jekyllbot | 68361c37ed | |
Ashwin Maroli | 895ab6c45b | |
jekyllbot | 3b99176f14 | |
Florian Klampfer | 331903536d | |
Frank Taillandier | 40ef3ae227 | |
Christian Oliff | ba0810c829 | |
jekyllbot | 0943563d0a | |
Martin Stühmer | 16a5e3d6b0 | |
jekyllbot | a937289d05 | |
Wei-Chung Liao | 39442c20c6 | |
jekyllbot | 242ad4f127 | |
jekyllbot | 32ce8914f4 | |
Frank Taillandier | 6bb46cc6d7 | |
jekyllbot | 4ca8035783 | |
Christian Oliff | 9befae460b | |
jekyllbot | d96bd7761f | |
Christian Oliff | e457314bfd | |
Frank Taillandier | e007a97175 | |
Christian Oliff | 0661e4d44d | |
jekyllbot | 2def9a6d23 | |
Christian Oliff | 10c1802175 | |
jekyllbot | aa9a279b8a | |
Christian Oliff | 664a9ea50c | |
Frank Taillandier | ec35d6a8c5 | |
Frank Taillandier | acc149372d | |
Ashwin Maroli | 531b25f971 | |
Frank Taillandier | 68e5ae2981 | |
jekyllbot | 8dfc4133ac | |
Ben Balter | 23ccab3a68 | |
jekyllbot | 451b2dca2b | |
jekyllbot | d2691d96ad | |
jekyllbot | a688cda0ac | |
Ashwin Maroli | 2f80d62208 | |
jekyllbot | ad3f7e3f48 | |
jekyllbot | 5bb39c54e2 | |
jekyllbot | f66eb193ab | |
Scott Watermasysk | 7898489736 | |
jekyllbot | 45c8eb7718 | |
Ashwin Maroli | 92450f130b | |
Ashwin Maroli | 8557598116 | |
jekyllbot | ded24a0254 | |
jekyllbot | 37829f05ab | |
Ashwin Maroli | 81b9bf16ba | |
jekyllbot | 20e50fad29 | |
Ashwin Maroli | cd82c88532 | |
Ashwin Maroli | 5aab527805 | |
Ashwin Maroli | 9b1001eb62 | |
Ashwin Maroli | d585dc3418 | |
Aleksey Spiridonov | 39269edc33 | |
jekyllbot | bb04d06a3e | |
jekyllbot | 31881b5273 | |
jekyllbot | a6fab73d5b | |
Ashwin Maroli | 28cc024648 | |
jekyllbot | 19fd87e0fe | |
jekyllbot | 3be2c5eabe | |
jekyllbot | 2184b8b201 | |
Ashwin Maroli | d8dba4bffa |
|
@ -0,0 +1,103 @@
|
|||
name: Continuous Integration
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
j4:
|
||||
if: "!contains(github.event.commits[0].message, '[ci skip]')"
|
||||
name: "Jekyll ${{ matrix.jekyll_version }} (Ruby ${{ matrix.ruby_version }})"
|
||||
runs-on: 'ubuntu-latest'
|
||||
env:
|
||||
JEKYLL_VERSION: ${{ matrix.jekyll_version }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
ruby_version:
|
||||
- 2.5
|
||||
- 2.7
|
||||
- 3.1
|
||||
jekyll_version:
|
||||
- "~> 4.0"
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 5
|
||||
- name: "Set up Ruby ${{ matrix.ruby_version }}"
|
||||
uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: ${{ matrix.ruby_version }}
|
||||
bundler-cache: true
|
||||
- name: Execute tests
|
||||
run: bundle exec rspec
|
||||
j3:
|
||||
if: "!contains(github.event.commits[0].message, '[ci skip]')"
|
||||
name: "Jekyll ${{ matrix.jekyll_version }} (Ruby ${{ matrix.ruby_version }})"
|
||||
runs-on: 'ubuntu-latest'
|
||||
env:
|
||||
JEKYLL_VERSION: ${{ matrix.jekyll_version }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
ruby_version:
|
||||
- 2.5
|
||||
jekyll_version:
|
||||
- "~> 3.9"
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 5
|
||||
- name: "Set up Ruby ${{ matrix.ruby_version }}"
|
||||
uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: ${{ matrix.ruby_version }}
|
||||
bundler-cache: true
|
||||
- name: Execute tests
|
||||
run: bundle exec rspec
|
||||
|
||||
style_check:
|
||||
if: "!contains(github.event.commits[0].message, '[ci skip]')"
|
||||
name: "Code Style Check (Ruby ${{ matrix.ruby_version }})"
|
||||
runs-on: 'ubuntu-latest'
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
ruby_version:
|
||||
- 2.5
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 5
|
||||
- name: "Set up Ruby ${{ matrix.ruby_version }}"
|
||||
uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: ${{ matrix.ruby_version }}
|
||||
bundler-cache: true
|
||||
- name: Check Style Offenses
|
||||
run: bundle exec rubocop -S -D
|
||||
|
||||
gem_build:
|
||||
if: "!contains(github.event.commits[0].message, '[ci skip]')"
|
||||
name: "Test Gem build (Ruby ${{ matrix.ruby_version }})"
|
||||
runs-on: 'ubuntu-latest'
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
ruby_version:
|
||||
- 2.5
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 5
|
||||
- name: "Set up Ruby ${{ matrix.ruby_version }}"
|
||||
uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: ${{ matrix.ruby_version }}
|
||||
bundler-cache: true
|
||||
- name: Test Gem build
|
||||
run: bundle exec gem build jekyll-seo-tag.gemspec
|
|
@ -0,0 +1,33 @@
|
|||
name: Release Gem
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
paths:
|
||||
- "lib/**/version.rb"
|
||||
|
||||
jobs:
|
||||
release:
|
||||
if: "github.repository_owner == 'jekyll'"
|
||||
name: "Release Gem (Ruby ${{ matrix.ruby_version }})"
|
||||
runs-on: "ubuntu-latest"
|
||||
strategy:
|
||||
fail-fast: true
|
||||
matrix:
|
||||
ruby_version:
|
||||
- 2.7
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v2
|
||||
- name: "Set up Ruby ${{ matrix.ruby_version }}"
|
||||
uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: ${{ matrix.ruby_version }}
|
||||
bundler-cache: true
|
||||
- name: Build and Publish Gem
|
||||
uses: ashmaroli/release-gem@dist
|
||||
with:
|
||||
gemspec_name: jekyll-seo-tag
|
||||
env:
|
||||
GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_GEM_PUSH_API_KEY }}
|
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
bundle exec ruby jekyll-seo-tag/.github/workflows/scripts/memprof.rb sandbox
|
||||
exit 0
|
|
@ -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)
|
|
@ -0,0 +1,63 @@
|
|||
name: Third-Party Repository Profiling
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
jobs:
|
||||
build_n_profile:
|
||||
name: "Third-Party Repo Profile (Jekyll ${{ matrix.jekyll_version }}, Ruby ${{ matrix.ruby_version }})"
|
||||
runs-on: "ubuntu-latest"
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
ruby_version:
|
||||
- 2.7
|
||||
jekyll_version:
|
||||
- "~> 4.0"
|
||||
- "~> 3.9"
|
||||
env:
|
||||
BUNDLE_GEMFILE: "sandbox/Gemfile"
|
||||
BUNDLE_PATH: "vendor/bundle"
|
||||
BUNDLE_JOBS: 4
|
||||
BUNDLE_RETRY: 3
|
||||
JEKYLL_VERSION: ${{ matrix.jekyll_version }}
|
||||
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 ${{ matrix.ruby_version }}"
|
||||
uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: ${{ matrix.ruby_version }}
|
||||
bundler-cache: true
|
||||
- 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: bash jekyll-seo-tag/.github/workflows/scripts/memprof
|
||||
if: "!contains(matrix.jekyll_version, '3.')"
|
|
@ -1,12 +1,9 @@
|
|||
/.bundle/
|
||||
/.yardoc
|
||||
/Gemfile.lock
|
||||
/_yardoc/
|
||||
/coverage/
|
||||
/doc/
|
||||
/pkg/
|
||||
/spec/reports/
|
||||
/tmp/
|
||||
/bin/
|
||||
*.gem
|
||||
_site
|
||||
.bundle
|
||||
.yardoc
|
||||
Gemfile.lock
|
||||
pkg
|
||||
spec/reports/
|
||||
spec/fixtures/.jekyll-cache
|
||||
tmp/
|
||||
vendor/bundle
|
||||
|
|
34
.rubocop.yml
34
.rubocop.yml
|
@ -1,20 +1,42 @@
|
|||
inherit_from: .rubocop_todo.yml
|
||||
|
||||
require: rubocop-jekyll
|
||||
inherit_gem:
|
||||
jekyll: .rubocop.yml
|
||||
rubocop-jekyll: .rubocop.yml
|
||||
|
||||
AllCops:
|
||||
TargetRubyVersion: 2.3
|
||||
TargetRubyVersion: 2.5
|
||||
SuggestExtensions: false
|
||||
Exclude:
|
||||
- vendor/**/*
|
||||
|
||||
Metrics/LineLength:
|
||||
Layout/LineEndStringConcatenationIndentation:
|
||||
Enabled: true
|
||||
Layout/LineLength:
|
||||
Exclude:
|
||||
- spec/**/*
|
||||
- jekyll-seo-tag.gemspec
|
||||
|
||||
Lint/EmptyInPattern:
|
||||
Enabled: false
|
||||
|
||||
Metrics/BlockLength:
|
||||
Exclude:
|
||||
- spec/**/*
|
||||
|
||||
Layout/IndentHeredoc:
|
||||
Exclude:
|
||||
- spec/**/*
|
||||
Naming/InclusiveLanguage:
|
||||
Enabled: false
|
||||
|
||||
Performance/MapCompact:
|
||||
Enabled: true
|
||||
Performance/RedundantEqualityComparisonBlock:
|
||||
Enabled: true
|
||||
Performance/RedundantSplitRegexpArgument:
|
||||
Enabled: true
|
||||
|
||||
Style/InPatternThen:
|
||||
Enabled: false
|
||||
Style/MultilineInPatternThen:
|
||||
Enabled: false
|
||||
Style/QuotedSymbols:
|
||||
Enabled: true
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
# This configuration was generated by
|
||||
# `rubocop --auto-gen-config --auto-gen-only-exclude`
|
||||
# on 2021-09-17 06:40:32 UTC using RuboCop version 1.18.4.
|
||||
# The point is for the user to remove these configuration records
|
||||
# one by one as the offenses are removed from the code base.
|
||||
# Note that changes in the inspected code, or installation of new
|
||||
# versions of RuboCop, may require this file to be generated again.
|
||||
|
||||
# Offense count: 1
|
||||
# Configuration parameters: AllowComments.
|
||||
Lint/EmptyClass:
|
||||
Exclude:
|
||||
- 'lib/jekyll-seo-tag/version.rb'
|
||||
|
||||
# Offense count: 3
|
||||
Lint/NoReturnInBeginEndBlocks:
|
||||
Exclude:
|
||||
- 'lib/jekyll-seo-tag/author_drop.rb'
|
||||
- 'lib/jekyll-seo-tag/drop.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# Cop supports --auto-correct.
|
||||
Lint/ToJSON:
|
||||
Exclude:
|
||||
- 'lib/jekyll-seo-tag/json_ld_drop.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# Configuration parameters: IgnoredMethods, Max.
|
||||
Metrics/PerceivedComplexity:
|
||||
Exclude:
|
||||
- 'lib/jekyll-seo-tag/drop.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# Configuration parameters: MinSize.
|
||||
Performance/CollectionLiteralInLoop:
|
||||
Exclude:
|
||||
- 'spec/jekyll_seo_tag/author_drop_spec.rb'
|
||||
|
||||
# Offense count: 9
|
||||
# Cop supports --auto-correct.
|
||||
Style/RedundantBegin:
|
||||
Exclude:
|
||||
- 'lib/jekyll-seo-tag.rb'
|
||||
- 'lib/jekyll-seo-tag/author_drop.rb'
|
||||
- 'lib/jekyll-seo-tag/drop.rb'
|
||||
- 'lib/jekyll-seo-tag/image_drop.rb'
|
13
.travis.yml
13
.travis.yml
|
@ -1,13 +0,0 @@
|
|||
rvm:
|
||||
- 2.3
|
||||
- 2.4
|
||||
- 2.5
|
||||
before_install: gem install bundler
|
||||
language: ruby
|
||||
script: script/cibuild
|
||||
sudo: false
|
||||
cache: bundler
|
||||
|
||||
env:
|
||||
global:
|
||||
- NOKOGIRI_USE_SYSTEM_LIBRARIES=true
|
3
Gemfile
3
Gemfile
|
@ -4,4 +4,5 @@ source "https://rubygems.org"
|
|||
|
||||
gemspec
|
||||
|
||||
gem "github-pages", :group => :jekyll_plugins
|
||||
gem "jekyll", ENV["JEKYLL_VERSION"] if ENV["JEKYLL_VERSION"]
|
||||
gem "kramdown-parser-gfm" if ENV["JEKYLL_VERSION"] == "~> 3.9"
|
||||
|
|
104
History.markdown
104
History.markdown
|
@ -1,9 +1,113 @@
|
|||
## HEAD
|
||||
|
||||
### Development Fixes
|
||||
|
||||
* Add Ruby 3.1 to CI matrix (#459)
|
||||
* chore: remove git.io (#462)
|
||||
|
||||
### Minor Enhancements
|
||||
|
||||
* Added the `twitter:description` tag (#464)
|
||||
* Support for image paths relative to the page's directory (#466)
|
||||
* Truncate the description value to 100 words (#492)
|
||||
|
||||
## 2.8.0 / 2022-02-04
|
||||
|
||||
### Minor Enhancements
|
||||
|
||||
* Allow to set type for author (#427)
|
||||
* Allow setting `author.url` (#453)
|
||||
* Implement Facebook domain verification (#455)
|
||||
* Add `og:image:alt` and `twitter:image:alt` (#438)
|
||||
* Sort JSON-LD data by key (#458)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Set the default `og:type` to 'website' (#391)
|
||||
* Template: Remove double new line (#454)
|
||||
|
||||
### Development Fixes
|
||||
|
||||
* Fix typo in source code comment (#449)
|
||||
* Set up Continuous Integration via GH Actions (#450)
|
||||
* Bump RuboCop to v1.18.x (#452)
|
||||
* Add workflow to release gem via GH Actions
|
||||
|
||||
## 2.7.1 / 2020-10-18
|
||||
|
||||
### Development Fixes
|
||||
|
||||
* 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
|
||||
|
||||
* 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
|
||||
|
||||
### Development Fixes
|
||||
|
||||
* Test against Jekyll 4.x (#336)
|
||||
|
||||
## 2.6.0 / 2019-03-16
|
||||
|
||||
### Minor Enhancements
|
||||
|
||||
* Twitter Image and Title (#330)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Do not cache the drop payload for SeoTag (#306)
|
||||
* Update url of schema website (#296)
|
||||
|
||||
### Development Fixes
|
||||
|
||||
* Relax version constraint on Bundler (#325)
|
||||
* chore(ci): Add Ruby 2.6, drop Ruby 2.3 (#326)
|
||||
* chore (ci): remove deprecated `sudo: false` in .travis.yml (#333)
|
||||
* Lint Ruby code with rubocop-jekyll gem (#302)
|
||||
* chore(deps): bump rubocop-jekyll to v0.4 (#320)
|
||||
* chore(deps): bump rubocop-jekyll to v0.3 (#316)
|
||||
* Correct RuboCop offenses in spec files (#319)
|
||||
|
||||
### Documentation
|
||||
|
||||
* Rectify error in Usage documentation (#328)
|
||||
|
||||
## 2.5.0 / 2018-05-18
|
||||
|
||||
* Docs: Prevent GitHub Pages from processing Liquid raw tag (#276)
|
||||
|
|
|
@ -12,8 +12,8 @@ Jekyll SEO Tag adds the following meta tags to your site:
|
|||
* Page description
|
||||
* Canonical URL
|
||||
* Next and previous URLs on paginated pages
|
||||
* [JSON-LD Site and post metadata](https://developers.google.com/structured-data/) for richer indexing
|
||||
* [Open Graph](http://ogp.me/) title, description, site title, and URL (for Facebook, LinkedIn, etc.)
|
||||
* [JSON-LD Site and post metadata](https://developers.google.com/search/docs/guides/intro-structured-data) for richer indexing
|
||||
* [Open Graph](https://ogp.me/) title, description, site title, and URL (for Facebook, LinkedIn, etc.)
|
||||
* [Twitter Summary Card](https://dev.twitter.com/cards/overview) metadata
|
||||
|
||||
While you could theoretically add the necessary metadata tags yourself, Jekyll SEO Tag provides a battle-tested template of crowdsourced best-practices.
|
||||
|
|
|
@ -68,14 +68,49 @@ There are several ways to convey this author-specific information. Author inform
|
|||
author: benbalter
|
||||
```
|
||||
|
||||
#### Setting author url
|
||||
|
||||
Starting from August 6, 2021 [Google recommends](https://developers.google.com/search/updates) to set the `author.url` property. This property helps Google to disambiguate the correct author of the article.
|
||||
|
||||
You can set it the same way as the other author properties. For example, you can put it in an `author` object, in the site's `_config.yml`, e.g.:
|
||||
|
||||
```yml
|
||||
author:
|
||||
name: My Name
|
||||
url: https://example.com/
|
||||
```
|
||||
|
||||
### Customizing description length
|
||||
|
||||
By default, the description is limited to the first 100 words of the full content.
|
||||
|
||||
You can adjust this limit at the page level, by using the `seo_description_max_words` page property:
|
||||
|
||||
```yml
|
||||
seo_description_max_words: 200
|
||||
```
|
||||
|
||||
You can also set a default site-wide value for all pages using [Front Matter defaults](https://jekyllrb.com/docs/configuration/front-matter-defaults/) in your `_config.yml` file:
|
||||
|
||||
```yml
|
||||
defaults:
|
||||
- scope:
|
||||
path: ""
|
||||
values:
|
||||
seo_description_max_words: 200
|
||||
```
|
||||
|
||||
|
||||
### Customizing JSON-LD output
|
||||
|
||||
The following options can be set for any particular page. While the default options are meant to serve most users in the most common circumstances, there may be situations where more precise control is necessary.
|
||||
|
||||
* `seo`
|
||||
* `name` - If the name of the thing that the page represents is different from the page title. (i.e.: "Frank's Café" vs "Welcome to Frank's Café")
|
||||
* `type` - The type of things that the page represents. This must be a [Schema.org type](http://schema.org/docs/schemas.html), and will probably usually be something like [`BlogPosting`](http://schema.org/BlogPosting), [`NewsArticle`](http://schema.org/NewsArticle), [`Person`](http://schema.org/Person), [`Organization`](http://schema.org/Organization), etc.
|
||||
* `type` - The type of things that the page represents. This must be a [Schema.org type](https://schema.org/docs/schemas.html), and will probably usually be something like [`BlogPosting`](https://schema.org/BlogPosting), [`NewsArticle`](https://schema.org/NewsArticle), [`Person`](https://schema.org/Person), [`Organization`](https://schema.org/Organization), etc.
|
||||
* `links` - An array of other URLs that represent the same thing that this page represents. For instance, Jane's bio page might include links to Jane's GitHub and Twitter profiles.
|
||||
* `date_modified` - Manually specify the `dateModified` field in the JSON-LD output to override Jekyll's own `dateModified`.
|
||||
This field will take **first priority** for the `dateModified` JSON-LD output. This is useful when the file timestamp does not match the true time that the content was modified. A user may also install [Last Modified At](https://github.com/gjtorikian/jekyll-last-modified-at) which will offer an alternative way of providing for the `dateModified` field.
|
||||
|
||||
### Customizing image output
|
||||
|
||||
|
@ -84,6 +119,7 @@ For most users, setting `image: [path-to-image]` on a per-page basis should be e
|
|||
* `path` - The relative path to the image. Same as `image: [path-to-image]`
|
||||
* `height` - The height of the Open Graph (`og:image`) image
|
||||
* `width` - The width of the Open Graph (`og:image`) image
|
||||
* `alt` - The alternative image text for Open Graph (`og:image:alt`) and Twitter (`twitter:image:alt`)
|
||||
|
||||
You can use any of the above, optional properties, like so:
|
||||
|
||||
|
@ -92,11 +128,12 @@ image:
|
|||
path: /img/twitter.png
|
||||
height: 100
|
||||
width: 100
|
||||
alt: Twitter Logo
|
||||
```
|
||||
|
||||
### Setting a default image
|
||||
|
||||
You can define a default image using [Front Matter default](https://jekyllrb.com/docs/configuration/#front-matter-defaults), to provide a default Twitter Card or OGP image to all of your posts and pages.
|
||||
You can define a default image using [Front Matter defaults](https://jekyllrb.com/docs/configuration/front-matter-defaults/), to provide a default Twitter Card or OGP image to all of your posts and pages.
|
||||
|
||||
Here is a very basic example, that you are encouraged to adapt to your needs:
|
||||
|
||||
|
@ -110,11 +147,11 @@ defaults:
|
|||
|
||||
### SmartyPants Titles
|
||||
|
||||
Titles will be processed using [Jekyll's `smartify` filter](https://jekyllrb.com/docs/templates/). This will use SmartyPants to translate plain ASCII punctuation into "smart" typographic punctuation. This will not render or strip any Markdown you may be using in a page title.
|
||||
Titles will be processed using [Jekyll's `smartify` filter](https://jekyllrb.com/docs/liquid/filters/). This will use SmartyPants to translate plain ASCII punctuation into "smart" typographic punctuation. This will not render or strip any Markdown you may be using in a page title.
|
||||
|
||||
### Setting customized Canonical URL
|
||||
|
||||
You can set custom Canonical URL for a page by specifying canonical_url option in page front-matter.
|
||||
You can set custom Canonical URL for a page by specifying canonical_url option in page front matter.
|
||||
E.g., you have the following in the page's front matter:
|
||||
```yml
|
||||
layout: post
|
||||
|
@ -128,7 +165,7 @@ Which will generate canonical_url with specified link in canonical_url.
|
|||
```
|
||||
|
||||
If no canonical_url option was specified, then uses page url for generating canonical_url.
|
||||
E.g., you have not specified canonical_url in front-matter:
|
||||
E.g., you have not specified canonical_url in front matter:
|
||||
```yml
|
||||
layout: post
|
||||
title: Title of Your Post
|
||||
|
@ -136,5 +173,19 @@ title: Title of Your Post
|
|||
|
||||
Which will generate following canonical_url:
|
||||
```html
|
||||
<link rel="canonical" href="http://yoursite.com/title-of-your-post" />
|
||||
<link rel="canonical" href="https://example.com/title-of-your-post" />
|
||||
```
|
||||
|
||||
### Customizing title modifier for paginated pages
|
||||
|
||||
You can override the default title modifier for paginated pages from `Page %{current} of %{total} for ` to a string of your
|
||||
choice by setting a `seo_paginator_message` key in your `_config.yml`.
|
||||
|
||||
For example:
|
||||
|
||||
```yml
|
||||
seo_paginator_message: "%<current>s / %<total>s | "
|
||||
```
|
||||
|
||||
While the value can be any string text, we recommend using a Ruby string-template containing the variables `current` and `total`
|
||||
similar to the example above, to incorporate the current page-number and total number of paginated pages in the title.
|
||||
|
|
|
@ -1,22 +1,29 @@
|
|||
## Usage
|
||||
|
||||
The SEO tag will respect any of the following if included in your site's `_config.yml` (and simply not include them if they're not defined):
|
||||
The SEO tag will respect any of the following if included in your site's `_config.yml` (and simply not include them if
|
||||
they're not defined):
|
||||
|
||||
* `title` - Your site's title (e.g., Ben's awesome site, The GitHub Blog, etc.)
|
||||
* `description` - A short description (e.g., A blog dedicated to reviewing cat gifs)
|
||||
* `title` - Your site's title (e.g., *Ben's Awesome Site*, *The GitHub Blog*, etc.), used as part of the title tag like
|
||||
`Home | Ben's Awesome Site`.
|
||||
* `tagline` - A short description (e.g., *A blog dedicated to reviewing cat gifs*), used as part of the title tag like
|
||||
`Ben's Awesome Site | A blog dedicated to reviewing cat gifs` instead of `Ben's Awesome Site | Long description about a
|
||||
blog dedicated to reviewing cat gifs` that would be used when `page.title` is not defined.
|
||||
* `description` - A longer description used for the description meta tag. Also used as fallback for pages that don't
|
||||
provide their own `description`, and also as part of the page's title tag if neither `page.title` nor `site.tagline`
|
||||
has been defined.
|
||||
* `url` - The full URL to your site. Note: `site.github.url` will be used by default.
|
||||
* `author` - global author information (see [Advanced usage](advanced-usage.md#author-information))
|
||||
|
||||
* `twitter` - The following properties are available:
|
||||
* `twitter:card` - The site's default card type
|
||||
* `twitter:username` - The site's Twitter handle. You'll want to describe it like so:
|
||||
* `twitter:username` - The site's Twitter handle.
|
||||
|
||||
You'll want to describe them like so:
|
||||
|
||||
```yml
|
||||
twitter:
|
||||
username: benbalter
|
||||
card: summary
|
||||
```
|
||||
|
||||
* `facebook` - The following properties are available:
|
||||
* `facebook:app_id` - a Facebook app ID for Facebook insights
|
||||
* `facebook:publisher` - a Facebook page URL or ID of the publishing entity
|
||||
|
@ -30,12 +37,14 @@ The SEO tag will respect any of the following if included in your site's `_confi
|
|||
publisher: 1234
|
||||
admins: 1234
|
||||
```
|
||||
|
||||
* `logo` - URL to a site-wide logo (e.g., `/assets/your-company-logo.png`) - If you would like the "publisher" property to be present, you must add this field to your site's configuration, during the validation of the structured data by Google web master tools, if the `logo` field is not validated, you will find errors inherent to the publisher in the [structured datas test](https://search.google.com/structured-data/testing-tool/u/0/)
|
||||
* `social` - For [specifying social profiles](https://developers.google.com/structured-data/customize/social-profiles). The following properties are available:
|
||||
* `logo` - URL to a site-wide logo (e.g., `/assets/your-company-logo.png`) - If you would like the "publisher" property
|
||||
to be present, you must add this field to your site's configuration, during the validation of the structured data by
|
||||
Google Search Console, if the `logo` field is not validated, you will find errors inherent to the publisher in the
|
||||
[Rich Results Testing Tool](https://search.google.com/test/rich-results)
|
||||
* `social` - For [specifying social profiles](https://developers.google.com/search/docs/guides/enhance-site#add-your-sites-name-logo-and-social-links).
|
||||
The following properties are available:
|
||||
* `name` - If the user or organization name differs from the site's name
|
||||
* `links` - An array of links to social media profiles.
|
||||
* `date_modified` - Manually specify the `dateModified` field in the JSON-LD output to override Jekyll's own `dateModified`. This field will take **first priority** for the `dateModified` JSON-LD output. This is useful when the file timestamp does not match the true time that the content was modified. A user may also install [Last Modified At](https://github.com/gjtorikian/jekyll-last-modified-at) which will offer an alternative way of providing for the `dateModified` field.
|
||||
|
||||
```yml
|
||||
social:
|
||||
|
@ -44,24 +53,22 @@ The SEO tag will respect any of the following if included in your site's `_confi
|
|||
- https://twitter.com/BenBalter
|
||||
- https://www.facebook.com/ben.balter
|
||||
- https://www.linkedin.com/in/BenBalter
|
||||
- https://plus.google.com/+BenBalter
|
||||
- https://github.com/benbalter
|
||||
- https://keybase.io/benbalter
|
||||
```
|
||||
|
||||
* `google_site_verification` for verifying ownership via Google webmaster tools
|
||||
* `google_site_verification` for verifying ownership via Google Search Console
|
||||
* Alternatively, verify ownership with several services at once using the following format:
|
||||
|
||||
```yml
|
||||
webmaster_verifications:
|
||||
google: 1234
|
||||
bing: 1234
|
||||
alexa: 1234
|
||||
yandex: 1234
|
||||
baidu: 1234
|
||||
```
|
||||
|
||||
* `lang` - The locale these tags are marked up in. Of the format `language_TERRITORY`. Default is `en_US`.
|
||||
```yml
|
||||
webmaster_verifications:
|
||||
google: 1234
|
||||
bing: 1234
|
||||
alexa: 1234
|
||||
yandex: 1234
|
||||
baidu: 1234
|
||||
facebook: 1234
|
||||
```
|
||||
* `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:
|
||||
|
||||
|
@ -69,6 +76,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.
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
lib = File.expand_path("lib", __dir__)
|
||||
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
||||
require "jekyll-seo-tag/version"
|
||||
require_relative "lib/jekyll-seo-tag/version"
|
||||
|
||||
Gem::Specification.new do |spec|
|
||||
spec.name = "jekyll-seo-tag"
|
||||
|
@ -10,7 +8,7 @@ Gem::Specification.new do |spec|
|
|||
spec.authors = ["Ben Balter"]
|
||||
spec.email = ["ben.balter@github.com"]
|
||||
spec.summary = "A Jekyll plugin to add metadata tags for search engines and social networks to better index and display your site's content."
|
||||
spec.homepage = "https://github.com/benbalter/jekyll-seo-tag"
|
||||
spec.homepage = "https://github.com/jekyll/jekyll-seo-tag"
|
||||
spec.license = "MIT"
|
||||
|
||||
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
||||
|
@ -21,16 +19,16 @@ 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.5.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"
|
||||
spec.add_development_dependency "bundler", "~> 1.15"
|
||||
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"
|
||||
spec.add_development_dependency "rubocop", "~> 0.56.0"
|
||||
spec.add_development_dependency "rubocop-jekyll", "~> 0.12.0"
|
||||
end
|
||||
|
|
|
@ -24,7 +24,7 @@ module Jekyll
|
|||
# We will not strip any whitespace if the next character is a '-'
|
||||
# so that we do not interfere with the HTML comment at the
|
||||
# very begining
|
||||
MINIFY_REGEX = %r!(?<=[{}]|[>,]\n)\s+(?\!-)!
|
||||
MINIFY_REGEX = %r!(?<=[{}]|[>,]\n)\s+(?\!-)!.freeze
|
||||
|
||||
def initialize(_tag_name, text, _tokens)
|
||||
super
|
||||
|
@ -46,21 +46,20 @@ module Jekyll
|
|||
end
|
||||
|
||||
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,
|
||||
})
|
||||
# site_payload is an instance of UnifiedPayloadDrop. See https://github.com/jekyll/jekyll/blob/22f2724a1f117a94cc16d18c499a93d5915ede4f/lib/jekyll/site.rb#L261-L276
|
||||
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
|
||||
|
||||
# The `drop` should not be cached since there is going to be just
|
||||
# one instance of this class per `{% seo %}`
|
||||
# i.e., if you're going to use `{% seo %}` in two templates that are
|
||||
# collectively used by 50 documents, there's just going to be
|
||||
# **2 instances of this class** instead of a **100**.
|
||||
def drop
|
||||
Jekyll::SeoTag::Drop.new(@text, @context)
|
||||
if context.registers[:site].liquid_renderer.respond_to?(:cache)
|
||||
Jekyll::SeoTag::Drop.new(@text, @context)
|
||||
else
|
||||
@drop ||= Jekyll::SeoTag::Drop.new(@text, @context)
|
||||
end
|
||||
end
|
||||
|
||||
def info
|
||||
|
|
|
@ -19,6 +19,7 @@ module Jekyll
|
|||
# site - The Jekyll::Drops::SiteDrop
|
||||
def initialize(page: nil, site: nil)
|
||||
raise ArgumentError unless page && site
|
||||
|
||||
@mutations = {}
|
||||
@page = page
|
||||
@site = site
|
||||
|
@ -33,20 +34,21 @@ module Jekyll
|
|||
|
||||
def twitter
|
||||
return @twitter if defined? @twitter
|
||||
|
||||
twitter = author_hash["twitter"] || author_hash["name"]
|
||||
@twitter = twitter.is_a?(String) ? twitter.sub(%r!^@!, "") : nil
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
attr_reader :page
|
||||
attr_reader :site
|
||||
attr_reader :site, :page
|
||||
|
||||
# Finds the page author in the page.author, page.authors, or site.author
|
||||
#
|
||||
# Returns a string or hash representing the author
|
||||
def resolved_author
|
||||
return @resolved_author if defined? @resolved_author
|
||||
|
||||
sources = [page["author"]]
|
||||
sources << page["authors"].first if page["authors"].is_a?(Array)
|
||||
sources << site["author"]
|
||||
|
@ -61,6 +63,7 @@ module Jekyll
|
|||
@site_data_hash ||= begin
|
||||
return {} unless resolved_author.is_a?(String)
|
||||
return {} unless site.data["authors"].is_a?(Hash)
|
||||
|
||||
author_hash = site.data["authors"][resolved_author]
|
||||
author_hash.is_a?(Hash) ? author_hash : {}
|
||||
end
|
||||
|
@ -70,12 +73,15 @@ module Jekyll
|
|||
# including site-wide metadata if the author is provided as a string,
|
||||
# or an empty hash, if the author cannot be resolved
|
||||
def author_hash
|
||||
if resolved_author.is_a? Hash
|
||||
resolved_author
|
||||
elsif resolved_author.is_a? String
|
||||
{ "name" => resolved_author }.merge(site_data_hash)
|
||||
else
|
||||
{}
|
||||
@author_hash ||= begin
|
||||
case resolved_author
|
||||
when Hash
|
||||
resolved_author
|
||||
when String
|
||||
{ "name" => resolved_author }.merge!(site_data_hash)
|
||||
else
|
||||
{}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -6,15 +6,18 @@ module Jekyll
|
|||
include Jekyll::SeoTag::UrlHelper
|
||||
|
||||
TITLE_SEPARATOR = " | "
|
||||
FORMAT_STRING_METHODS = %i[
|
||||
markdownify strip_html normalize_whitespace escape_once
|
||||
FORMAT_STRING_METHODS = [
|
||||
:markdownify, :strip_html, :normalize_whitespace, :escape_once,
|
||||
].freeze
|
||||
HOMEPAGE_OR_ABOUT_REGEX = %r!^/(about/)?(index.html?)?$!
|
||||
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
|
||||
@text = text
|
||||
@context = context
|
||||
end
|
||||
|
||||
|
@ -26,6 +29,7 @@ module Jekyll
|
|||
def title?
|
||||
return false unless title
|
||||
return @display_title if defined?(@display_title)
|
||||
|
||||
@display_title = (@text !~ %r!title=false!i)
|
||||
end
|
||||
|
||||
|
@ -33,6 +37,10 @@ module Jekyll
|
|||
@site_title ||= format_string(site["title"] || site["name"])
|
||||
end
|
||||
|
||||
def site_tagline
|
||||
@site_tagline ||= format_string site["tagline"]
|
||||
end
|
||||
|
||||
def site_description
|
||||
@site_description ||= format_string site["description"]
|
||||
end
|
||||
|
@ -42,27 +50,32 @@ module Jekyll
|
|||
@page_title ||= format_string(page["title"]) || site_title
|
||||
end
|
||||
|
||||
def site_tagline_or_description
|
||||
site_tagline || site_description
|
||||
end
|
||||
|
||||
# Page title with site title or description appended
|
||||
# rubocop:disable Metrics/CyclomaticComplexity
|
||||
def title
|
||||
@title ||= begin
|
||||
if site_title && page_title != site_title
|
||||
page_title + TITLE_SEPARATOR + site_title
|
||||
elsif site_description && site_title
|
||||
site_title + TITLE_SEPARATOR + site_description
|
||||
site_title + TITLE_SEPARATOR + site_tagline_or_description
|
||||
else
|
||||
page_title || site_title
|
||||
end
|
||||
end
|
||||
|
||||
if page_number
|
||||
return page_number + @title
|
||||
end
|
||||
return page_number + @title if page_number
|
||||
|
||||
@title
|
||||
end
|
||||
# rubocop:enable Metrics/CyclomaticComplexity
|
||||
|
||||
def name
|
||||
return @name if defined?(@name)
|
||||
|
||||
@name = if seo_name
|
||||
seo_name
|
||||
elsif !homepage_or_about?
|
||||
|
@ -76,7 +89,8 @@ module Jekyll
|
|||
|
||||
def description
|
||||
@description ||= begin
|
||||
format_string(page["description"] || page["excerpt"]) || site_description
|
||||
value = format_string(page["description"] || page["excerpt"]) || site_description
|
||||
snippet(value, description_max_words)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -99,13 +113,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
|
||||
|
@ -141,6 +149,7 @@ module Jekyll
|
|||
def logo
|
||||
@logo ||= begin
|
||||
return unless site["logo"]
|
||||
|
||||
if absolute_url? site["logo"]
|
||||
filters.uri_escape site["logo"]
|
||||
else
|
||||
|
@ -153,6 +162,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?
|
||||
|
@ -163,6 +176,10 @@ module Jekyll
|
|||
end
|
||||
end
|
||||
|
||||
def description_max_words
|
||||
@description_max_words ||= page["seo_description_max_words"] || 100
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def filters
|
||||
|
@ -186,10 +203,9 @@ module Jekyll
|
|||
|
||||
current = @context["paginator"]["page"]
|
||||
total = @context["paginator"]["total_pages"]
|
||||
paginator_message = site["seo_paginator_message"] || "Page %<current>s of %<total>s for "
|
||||
|
||||
if current > 1
|
||||
return "Page #{current} of #{total} for "
|
||||
end
|
||||
format(paginator_message, :current => current, :total => total) if current > 1
|
||||
end
|
||||
|
||||
attr_reader :context
|
||||
|
@ -206,6 +222,13 @@ module Jekyll
|
|||
string unless string.empty?
|
||||
end
|
||||
|
||||
def snippet(string, max_words)
|
||||
return string if string.nil?
|
||||
|
||||
result = string.split(%r!\s+!, max_words + 1)[0...max_words].join(" ")
|
||||
result.length < string.length ? result.concat("…") : result
|
||||
end
|
||||
|
||||
def seo_name
|
||||
@seo_name ||= format_string(page_seo["name"]) if page_seo["name"]
|
||||
end
|
||||
|
@ -228,7 +251,7 @@ module Jekyll
|
|||
if hash[key].is_a?(Hash)
|
||||
hash[key]
|
||||
else
|
||||
{}
|
||||
EMPTY_READ_ONLY_HASH
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -18,6 +18,7 @@ module Jekyll
|
|||
# context - the Liquid::Context
|
||||
def initialize(page: nil, context: nil)
|
||||
raise ArgumentError unless page && context
|
||||
|
||||
@mutations = {}
|
||||
@page = page
|
||||
@context = context
|
||||
|
@ -33,18 +34,22 @@ module Jekyll
|
|||
|
||||
private
|
||||
|
||||
attr_accessor :page
|
||||
attr_accessor :context
|
||||
attr_accessor :page, :context
|
||||
|
||||
# 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"]
|
||||
|
||||
case image_meta
|
||||
when Hash
|
||||
{ "path" => nil }.merge!(image_meta)
|
||||
when String
|
||||
{ "path" => image_meta }
|
||||
else
|
||||
{ "path" => nil }
|
||||
end
|
||||
end
|
||||
end
|
||||
alias_method :fallback_data, :image_hash
|
||||
|
||||
|
@ -56,12 +61,18 @@ module Jekyll
|
|||
|
||||
def absolute_url
|
||||
return unless raw_path
|
||||
return @absolute_url if defined? @absolute_url
|
||||
@absolute_url = if raw_path.is_a?(String) && absolute_url?(raw_path) == false
|
||||
filters.absolute_url raw_path
|
||||
else
|
||||
raw_path
|
||||
end
|
||||
|
||||
@absolute_url ||= build_absolute_path
|
||||
end
|
||||
|
||||
def build_absolute_path
|
||||
return raw_path unless raw_path.is_a?(String) && absolute_url?(raw_path) == false
|
||||
return filters.absolute_url(raw_path) if raw_path.start_with?("/")
|
||||
|
||||
page_dir = @page["url"]
|
||||
page_dir = File.dirname(page_dir) unless page_dir.end_with?("/")
|
||||
|
||||
filters.absolute_url File.join(page_dir, raw_path)
|
||||
end
|
||||
|
||||
def filters
|
||||
|
|
|
@ -16,9 +16,12 @@ module Jekyll
|
|||
def_delegator :page_drop, :type, :type
|
||||
|
||||
# Expose #type and #logo as private methods and #@type as a public method
|
||||
alias_method :"@type", :type
|
||||
private :type
|
||||
private :logo
|
||||
alias_method :@type, :type
|
||||
private :type, :logo
|
||||
|
||||
VALID_ENTITY_TYPES = %w(BlogPosting CreativeWork).freeze
|
||||
VALID_AUTHOR_TYPES = %w(Organization Person).freeze
|
||||
private_constant :VALID_ENTITY_TYPES, :VALID_AUTHOR_TYPES
|
||||
|
||||
# page_drop should be an instance of Jekyll::SeoTag::Drop
|
||||
def initialize(page_drop)
|
||||
|
@ -27,17 +30,26 @@ module Jekyll
|
|||
end
|
||||
|
||||
def fallback_data
|
||||
{
|
||||
@fallback_data ||= {
|
||||
"@context" => "https://schema.org",
|
||||
}
|
||||
end
|
||||
|
||||
def author
|
||||
return unless page_drop.author["name"]
|
||||
{
|
||||
"@type" => "Person",
|
||||
|
||||
author_type = page_drop.author["type"]
|
||||
return if author_type && !VALID_AUTHOR_TYPES.include?(author_type)
|
||||
|
||||
hash = {
|
||||
"@type" => author_type || "Person",
|
||||
"name" => page_drop.author["name"],
|
||||
}
|
||||
|
||||
author_url = page_drop.author["url"]
|
||||
hash["url"] = author_url if author_url
|
||||
|
||||
hash
|
||||
end
|
||||
|
||||
def image
|
||||
|
@ -52,6 +64,7 @@ module Jekyll
|
|||
|
||||
def publisher
|
||||
return unless logo
|
||||
|
||||
output = {
|
||||
"@type" => "Organization",
|
||||
"logo" => {
|
||||
|
@ -64,7 +77,8 @@ module Jekyll
|
|||
end
|
||||
|
||||
def main_entity
|
||||
return unless %w(BlogPosting CreativeWork).include?(type)
|
||||
return unless VALID_ENTITY_TYPES.include?(type)
|
||||
|
||||
{
|
||||
"@type" => "WebPage",
|
||||
"@id" => page_drop.canonical_url,
|
||||
|
@ -73,8 +87,13 @@ module Jekyll
|
|||
alias_method :mainEntityOfPage, :main_entity
|
||||
private :main_entity
|
||||
|
||||
def to_json
|
||||
to_h.reject { |_k, v| v.nil? }.to_json
|
||||
# Returns a JSON-encoded object containing the JSON-LD data.
|
||||
# Keys are sorted.
|
||||
def to_json(state = nil)
|
||||
keys.sort.each_with_object({}) do |(key, _), result|
|
||||
v = self[key]
|
||||
result[key] = v unless v.nil?
|
||||
end.to_json(state)
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -8,11 +8,12 @@ module Jekyll
|
|||
|
||||
# Determines if the given string is an absolute URL
|
||||
#
|
||||
# Returns true if an absolute URL.
|
||||
# Retruns false if it's a relative URL
|
||||
# Returns true if an absolute URL
|
||||
# Returns false if it's a relative URL
|
||||
# Returns nil if it is not a string or can't be parsed as a URL
|
||||
def absolute_url?(string)
|
||||
return unless string
|
||||
|
||||
Addressable::URI.parse(string).absolute?
|
||||
rescue Addressable::URI::InvalidURIError
|
||||
nil
|
||||
|
|
|
@ -5,6 +5,6 @@ module Liquid; class Tag; end; end
|
|||
|
||||
module Jekyll
|
||||
class SeoTag < Liquid::Tag
|
||||
VERSION = "2.5.0"
|
||||
VERSION = "2.8.0"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,11 +13,12 @@
|
|||
<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 }}" />
|
||||
<meta property="og:description" content="{{ seo_tag.description }}" />
|
||||
<meta property="twitter:description" content="{{ seo_tag.description }}" />
|
||||
{% endif %}
|
||||
|
||||
{% if site.url %}
|
||||
|
@ -37,11 +38,16 @@
|
|||
{% if seo_tag.image.width %}
|
||||
<meta property="og:image:width" content="{{ seo_tag.image.width }}" />
|
||||
{% endif %}
|
||||
{% if seo_tag.image.alt %}
|
||||
<meta property="og:image:alt" content="{{ seo_tag.image.alt }}" />
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if page.date %}
|
||||
<meta property="og:type" content="article" />
|
||||
<meta property="article:published_time" content="{{ page.date | date_to_xmlschema }}" />
|
||||
{% else %}
|
||||
<meta property="og:type" content="website" />
|
||||
{% endif %}
|
||||
|
||||
{% if paginator.previous_page %}
|
||||
|
@ -51,17 +57,26 @@
|
|||
<link rel="next" href="{{ paginator.next_page_path | absolute_url }}" />
|
||||
{% endif %}
|
||||
|
||||
{% if site.twitter %}
|
||||
{% if seo_tag.image %}
|
||||
<meta name="twitter:card" content="{{ page.twitter.card | default: site.twitter.card | default: "summary_large_image" }}" />
|
||||
{% else %}
|
||||
<meta name="twitter:card" content="summary" />
|
||||
{% endif %}
|
||||
{% if seo_tag.image %}
|
||||
<meta name="twitter:card" content="{{ page.twitter.card | default: site.twitter.card | default: "summary_large_image" }}" />
|
||||
<meta property="twitter:image" content="{{ seo_tag.image.path }}" />
|
||||
{% else %}
|
||||
<meta name="twitter:card" content="summary" />
|
||||
{% endif %}
|
||||
|
||||
<meta name="twitter:site" content="@{{ site.twitter.username | replace:"@","" }}" />
|
||||
{% if seo_tag.image.alt %}
|
||||
<meta name="twitter:image:alt" content="{{ seo_tag.image.alt }}" />
|
||||
{% endif %}
|
||||
|
||||
{% if seo_tag.page_title %}
|
||||
<meta property="twitter:title" content="{{ seo_tag.page_title }}" />
|
||||
{% endif %}
|
||||
|
||||
{% if site.twitter %}
|
||||
<meta name="twitter:site" content="@{{ site.twitter.username | remove:'@' }}" />
|
||||
|
||||
{% if seo_tag.author.twitter %}
|
||||
<meta name="twitter:creator" content="@{{ seo_tag.author.twitter }}" />
|
||||
<meta name="twitter:creator" content="@{{ seo_tag.author.twitter | remove:'@' }}" />
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
|
@ -99,6 +114,10 @@
|
|||
{% if site.webmaster_verifications.baidu %}
|
||||
<meta name="baidu-site-verification" content="{{ site.webmaster_verifications.baidu }}" />
|
||||
{% endif %}
|
||||
|
||||
{% if site.webmaster_verifications.facebook %}
|
||||
<meta name="facebook-domain-verification" content="{{ site.webmaster_verifications.facebook }}" />
|
||||
{% endif %}
|
||||
{% elsif site.google_site_verification %}
|
||||
<meta name="google-site-verification" content="{{ site.google_site_verification }}" />
|
||||
{% endif %}
|
||||
|
|
|
@ -50,7 +50,7 @@ RSpec.describe Jekyll::SeoTag::AuthorDrop do
|
|||
end
|
||||
end
|
||||
|
||||
%i[with without].each do |site_data_type|
|
||||
[:with, :without].each do |site_data_type|
|
||||
context "#{site_data_type} site.author data" do
|
||||
let(:data) do
|
||||
if site_data_type == :with
|
||||
|
|
|
@ -84,6 +84,17 @@ RSpec.describe Jekyll::SeoTag::Drop do
|
|||
end
|
||||
end
|
||||
|
||||
context "with a site tagline but no page title" do
|
||||
let(:page) { make_page }
|
||||
let(:config) do
|
||||
{ "title" => "site title", "description" => "site description", "tagline" => "site tagline" }
|
||||
end
|
||||
|
||||
it "builds the title" do
|
||||
expect(subject.title).to eql("site title | site tagline")
|
||||
end
|
||||
end
|
||||
|
||||
context "with just a page title" do
|
||||
let(:site) { make_site }
|
||||
|
||||
|
@ -222,6 +233,24 @@ RSpec.describe Jekyll::SeoTag::Drop do
|
|||
expect(subject.description).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
context "truncation" do
|
||||
context "without seo_description_max_words" do
|
||||
let(:page_meta) { { "description" => "word " * 150 } }
|
||||
|
||||
it "truncates the description to the first 200 words" do
|
||||
expect(subject.description).to eql(("word " * 100).chop.concat("…"))
|
||||
end
|
||||
end
|
||||
|
||||
context "with an explicit seo_description_max_words property" do
|
||||
let(:page_meta) { { "description" => "For a long time, I went to bed early", "seo_description_max_words" => 6 } }
|
||||
|
||||
it "truncates the description to the configured words count" do
|
||||
expect(subject.description).to eql("For a long time, I went…")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "author" do
|
||||
|
@ -320,7 +349,7 @@ RSpec.describe Jekyll::SeoTag::Drop do
|
|||
end
|
||||
|
||||
context "the about page" do
|
||||
let(:page) { make_page({ "permalink" => "/about/" }) }
|
||||
let(:page) { make_page("permalink" => "/about/") }
|
||||
|
||||
it "is a website" do
|
||||
expect(subject.type).to eql("WebSite")
|
||||
|
@ -404,7 +433,7 @@ RSpec.describe Jekyll::SeoTag::Drop do
|
|||
end
|
||||
|
||||
context "image" do
|
||||
let(:image) { "foo.png" }
|
||||
let(:image) { "/foo.png" }
|
||||
let(:page_meta) { { "image" => image } }
|
||||
|
||||
it "returns a Drop" do
|
||||
|
@ -482,6 +511,27 @@ RSpec.describe Jekyll::SeoTag::Drop do
|
|||
end
|
||||
end
|
||||
|
||||
context "pagination" do
|
||||
let(:context) do
|
||||
make_context(
|
||||
{ :page => page, :site => site },
|
||||
"paginator" => { "page" => 2, "total_pages" => 10 }
|
||||
)
|
||||
end
|
||||
|
||||
it "render default pagination title" do
|
||||
expect(subject.send(:page_number)).to eq("Page 2 of 10 for ")
|
||||
end
|
||||
|
||||
context "render custom pagination title" do
|
||||
let(:config) { { "seo_paginator_message" => "%<current>s of %<total>s" } }
|
||||
|
||||
it "renders the correct page number" do
|
||||
expect(subject.send(:page_number)).to eq("2 of 10")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
it "exposes the JSON-LD drop" do
|
||||
expect(subject.json_ld).to be_a(Jekyll::SeoTag::JSONLDDrop)
|
||||
end
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
RSpec.describe Jekyll::SeoTag::ImageDrop do
|
||||
let(:config) { { "title" => "site title" } }
|
||||
let(:image) { nil }
|
||||
let(:page_meta) { { "image" => image } }
|
||||
let(:page_meta) { { "image" => image, "dir" => "foo" } }
|
||||
let(:page) { make_page(page_meta) }
|
||||
let(:site) { make_site(config) }
|
||||
let(:context) { make_context(:page => page, :site => site) }
|
||||
|
@ -14,8 +14,34 @@ RSpec.describe Jekyll::SeoTag::ImageDrop do
|
|||
Jekyll.logger.log_level = :error
|
||||
end
|
||||
|
||||
context "with image as a string" do
|
||||
context "with a post object" do
|
||||
let(:image) { "image.png" }
|
||||
let(:page_meta) { { "image" => image, "date" => "2017-01-01" } }
|
||||
let(:page) { make_post(page_meta) }
|
||||
|
||||
it "returns the image url relative to the post directory" do
|
||||
expect(subject["path"]).to eql("/2017/01/01/image.png")
|
||||
end
|
||||
end
|
||||
|
||||
context "with image as a relative path" do
|
||||
let(:image) { "image.png" }
|
||||
|
||||
it "returns the image with the page dir prepended" do
|
||||
expect(subject["path"]).to eql("/foo/image.png")
|
||||
end
|
||||
|
||||
context "with site.url" do
|
||||
let(:config) { { "url" => "http://example.com" } }
|
||||
|
||||
it "makes the path absolute" do
|
||||
expect(subject["path"]).to eql("http://example.com/foo/image.png")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "with image as an absolute path" do
|
||||
let(:image) { "/image.png" }
|
||||
|
||||
it "returns the image" do
|
||||
expect(subject["path"]).to eql("/image.png")
|
||||
|
@ -30,7 +56,7 @@ RSpec.describe Jekyll::SeoTag::ImageDrop do
|
|||
end
|
||||
|
||||
context "with a URL-escaped path" do
|
||||
let(:image) { "some image.png" }
|
||||
let(:image) { "/some image.png" }
|
||||
|
||||
it "URL-escapes the image" do
|
||||
expect(subject["path"]).to eql("/some%20image.png")
|
||||
|
@ -39,8 +65,8 @@ RSpec.describe Jekyll::SeoTag::ImageDrop do
|
|||
end
|
||||
|
||||
context "with image as a hash" do
|
||||
context "with a path" do
|
||||
let(:image) { { "path" => "image.png" } }
|
||||
context "with an absolute path" do
|
||||
let(:image) { { "path" => "/image.png" } }
|
||||
|
||||
it "returns the image" do
|
||||
expect(subject["path"]).to eql("/image.png")
|
||||
|
@ -48,7 +74,7 @@ RSpec.describe Jekyll::SeoTag::ImageDrop do
|
|||
end
|
||||
|
||||
context "with facebook" do
|
||||
let(:image) { { "facebook" => "image.png" } }
|
||||
let(:image) { { "facebook" => "/image.png" } }
|
||||
|
||||
it "returns the image" do
|
||||
expect(subject["path"]).to eql("/image.png")
|
||||
|
@ -56,7 +82,7 @@ RSpec.describe Jekyll::SeoTag::ImageDrop do
|
|||
end
|
||||
|
||||
context "with twitter" do
|
||||
let(:image) { { "twitter" => "image.png" } }
|
||||
let(:image) { { "twitter" => "/image.png" } }
|
||||
|
||||
it "returns the image" do
|
||||
expect(subject["path"]).to eql("/image.png")
|
||||
|
|
|
@ -69,14 +69,52 @@ RSpec.describe Jekyll::SeoTag::JSONLDDrop do
|
|||
expect(subject["author"]).to have_key("name")
|
||||
expect(subject["author"]["name"]).to be_a(String)
|
||||
expect(subject["author"]["name"]).to eql("author")
|
||||
expect(subject["author"]["url"]).to be nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "when type Organization" do
|
||||
let(:author) { { "name" => "organization", "type" => "Organization" } }
|
||||
|
||||
it "returns the author with type" do
|
||||
expect(subject).to have_key("author")
|
||||
expect(subject["author"]).to be_a(Hash)
|
||||
expect(subject["author"]).to have_key("@type")
|
||||
expect(subject["author"]["@type"]).to eql("Organization")
|
||||
expect(subject["author"]).to have_key("name")
|
||||
expect(subject["author"]["name"]).to be_a(String)
|
||||
expect(subject["author"]["name"]).to eql("organization")
|
||||
end
|
||||
end
|
||||
|
||||
context "when invalid type" do
|
||||
let(:author) { { "name" => "organization", "type" => "Invalid" } }
|
||||
|
||||
it "returns the author with type" do
|
||||
expect(subject).to have_key("author")
|
||||
expect(subject["author"]).to be nil
|
||||
end
|
||||
end
|
||||
|
||||
context "when url is present" do
|
||||
let(:author) { { "name" => "author", "url" => "https://example.com" } }
|
||||
|
||||
it "returns the author with url" do
|
||||
expect(subject).to have_key("author")
|
||||
expect(subject["author"]).to be_a(Hash)
|
||||
expect(subject["author"]).to have_key("url")
|
||||
expect(subject["author"]["url"]).to eql("https://example.com")
|
||||
expect(subject["author"]).to have_key("name")
|
||||
expect(subject["author"]["name"]).to be_a(String)
|
||||
expect(subject["author"]["name"]).to eql("author")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "image" do
|
||||
context "with image as a string" do
|
||||
let(:image) { "image" }
|
||||
context "with image as an absolute path" do
|
||||
let(:image) { "/image" }
|
||||
|
||||
it "returns the image as a string" do
|
||||
expect(subject).to have_key("image")
|
||||
|
@ -86,17 +124,17 @@ RSpec.describe Jekyll::SeoTag::JSONLDDrop do
|
|||
end
|
||||
|
||||
context "with image as a hash" do
|
||||
let(:image) { { "path" => "image", "height" => 5, "width" => 10 } }
|
||||
let(:image) { { "path" => "/image", "height" => 5, "width" => 10 } }
|
||||
|
||||
it "returns the image as a hash" do
|
||||
expect(subject).to have_key("image")
|
||||
expect(subject["image"]).to be_a(Hash)
|
||||
expect(subject["image"]).to eql({
|
||||
expect(subject["image"]).to eql(
|
||||
"@type" => "imageObject",
|
||||
"url" => "/image",
|
||||
"height" => 5,
|
||||
"width" => 10,
|
||||
})
|
||||
"width" => 10
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,7 +8,7 @@ RSpec.describe Jekyll::SeoTag do
|
|||
let(:tag) { "seo" }
|
||||
let(:text) { "" }
|
||||
let(:output) { Liquid::Template.parse("{% #{tag} #{text} %}").render!(context, {}) }
|
||||
let(:json) { output.match(%r!<script type=\"application/ld\+json\">(.*)</script>!m)[1] }
|
||||
let(:json) { output.match(%r!<script type="application/ld\+json">(.*)</script>!m)[1] }
|
||||
let(:json_data) { JSON.parse(json) }
|
||||
let(:paginator) { { "previous_page" => true, "previous_page_path" => "foo", "next_page" => true, "next_page_path" => "bar" } }
|
||||
|
||||
|
@ -26,7 +26,12 @@ RSpec.describe Jekyll::SeoTag do
|
|||
end
|
||||
|
||||
it "outputs meta generator" do
|
||||
expect(output).to match(%r!Jekyll v#{Jekyll::VERSION}!i)
|
||||
version = Jekyll::VERSION
|
||||
expect(output).to match(%r!Jekyll v#{version}!i)
|
||||
end
|
||||
|
||||
it "outputs JSON sorted by key" do
|
||||
expect(json.strip).to eql('{"@context":"https://schema.org","@type":"WebPage","url":"/page.html"}')
|
||||
end
|
||||
|
||||
it "outputs valid HTML" do
|
||||
|
@ -119,6 +124,7 @@ RSpec.describe Jekyll::SeoTag do
|
|||
it "uses the page description" do
|
||||
expect(output).to match(%r!<meta name="description" content="foo" />!)
|
||||
expect(output).to match(%r!<meta property="og:description" content="foo" />!)
|
||||
expect(output).to match(%r!<meta property="twitter:description" content="foo" />!)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -128,6 +134,7 @@ RSpec.describe Jekyll::SeoTag do
|
|||
it "uses the page excerpt when no page description exists" do
|
||||
expect(output).to match(%r!<meta name="description" content="foo" />!)
|
||||
expect(output).to match(%r!<meta property="og:description" content="foo" />!)
|
||||
expect(output).to match(%r!<meta property="twitter:description" content="foo" />!)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -137,6 +144,7 @@ RSpec.describe Jekyll::SeoTag do
|
|||
it "uses the site description when no page description nor excerpt exist" do
|
||||
expect(output).to match(%r!<meta name="description" content="foo" />!)
|
||||
expect(output).to match(%r!<meta property="og:description" content="foo" />!)
|
||||
expect(output).to match(%r!<meta property="twitter:description" content="foo" />!)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -299,16 +307,16 @@ RSpec.describe Jekyll::SeoTag do
|
|||
|
||||
it "minifies the output" do
|
||||
version = Jekyll::SeoTag::VERSION
|
||||
expected = <<-EOS
|
||||
<!-- Begin Jekyll SEO tag v#{version} -->
|
||||
<title>Foo</title>
|
||||
<meta name="generator" content="Jekyll v#{Jekyll::VERSION}" />
|
||||
<meta property="og:title" content="Foo" />
|
||||
<meta property="og:locale" content="en_US" />
|
||||
<link rel="canonical" href="http://example.invalid/page.html" />
|
||||
<meta property="og:url" content="http://example.invalid/page.html" />
|
||||
<meta property="og:site_name" content="Foo" />
|
||||
EOS
|
||||
expected = <<~HTML
|
||||
<!-- Begin Jekyll SEO tag v#{version} -->
|
||||
<title>Foo</title>
|
||||
<meta name="generator" content="Jekyll v#{Jekyll::VERSION}" />
|
||||
<meta property="og:title" content="Foo" />
|
||||
<meta property="og:locale" content="en_US" />
|
||||
<link rel="canonical" href="http://example.invalid/page.html" />
|
||||
<meta property="og:url" content="http://example.invalid/page.html" />
|
||||
<meta property="og:site_name" content="Foo" />
|
||||
HTML
|
||||
expect(output).to match(expected)
|
||||
end
|
||||
end
|
||||
|
@ -342,6 +350,23 @@ EOS
|
|||
it "removes null values from JSON-LD" do
|
||||
expect(output).to_not match(%r!:null!)
|
||||
end
|
||||
|
||||
context "description" do
|
||||
context "with page.seo_description_max_words" do
|
||||
let(:meta) do
|
||||
{
|
||||
"title" => "post",
|
||||
"description" => "For a long time, I went to bed early",
|
||||
"image" => "/img.png",
|
||||
"seo_description_max_words" => 6,
|
||||
}
|
||||
end
|
||||
|
||||
it "truncates the description" do
|
||||
expect(json_data["description"]).to eql("For a long time, I went…")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -613,10 +638,11 @@ EOS
|
|||
context "with site.webmaster_verifications" do
|
||||
let(:site_verifications) do
|
||||
{
|
||||
"google" => "foo",
|
||||
"bing" => "bar",
|
||||
"alexa" => "baz",
|
||||
"yandex" => "bat",
|
||||
"google" => "foo",
|
||||
"bing" => "bar",
|
||||
"alexa" => "baz",
|
||||
"yandex" => "bat",
|
||||
"facebook" => "bas",
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -641,6 +667,11 @@ EOS
|
|||
expected = %r!<meta name="yandex-verification" content="bat" />!
|
||||
expect(output).to match(expected)
|
||||
end
|
||||
|
||||
it "outputs facebook verification meta" do
|
||||
expected = %r!<meta name="facebook-domain-verification" content="bas" />!
|
||||
expect(output).to match(expected)
|
||||
end
|
||||
end
|
||||
|
||||
context "with site.google_site_verification" do
|
||||
|
@ -660,10 +691,10 @@ EOS
|
|||
end
|
||||
|
||||
context "with site.lang" do
|
||||
let(:site) { make_site("lang" => "en_US") }
|
||||
let(:site) { make_site("lang" => "de_DE") }
|
||||
|
||||
it "uses site.lang if page.lang is not present" do
|
||||
expected = %r!<meta property="og:locale" content="en_US" />!
|
||||
expected = %r!<meta property="og:locale" content="de_DE" />!
|
||||
expect(output).to match(expected)
|
||||
end
|
||||
|
||||
|
@ -678,10 +709,10 @@ EOS
|
|||
end
|
||||
|
||||
context "with site.lang hyphenated" do
|
||||
let(:site) { make_site("lang" => "en-US") }
|
||||
let(:site) { make_site("lang" => "en-AU") }
|
||||
|
||||
it "coerces hyphen to underscore" do
|
||||
expected = %r!<meta property="og:locale" content="en_US" />!
|
||||
expected = %r!<meta property="og:locale" content="en_AU" />!
|
||||
expect(output).to match(expected)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -31,7 +31,7 @@ CONFIG_DEFAULTS = {
|
|||
}.freeze
|
||||
|
||||
def make_page(options = {})
|
||||
page = Jekyll::Page.new site, CONFIG_DEFAULTS["source"], "", "page.md"
|
||||
page = Jekyll::Page.new site, CONFIG_DEFAULTS["source"], options.delete("dir") || "", "page.md"
|
||||
page.data = options
|
||||
page
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue