Merge pull request #123 from jekyll/pr/newfilters

Use new URL filters
This commit is contained in:
Pat Hawks 2016-10-06 16:14:12 -05:00 committed by GitHub
commit 7b5ade75ae
7 changed files with 15 additions and 44 deletions

View File

@ -9,6 +9,7 @@ group :development, :test do
versions.delete('ruby')
versions.delete('jekyll-seo-tag')
versions.delete('github-pages')
versions.delete('jekyll') # Remove this line when GitHub Pages supports 3.3.0
versions.each do |dep, version|
gem dep, version

View File

@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ['lib']
spec.add_dependency 'jekyll', '~> 3.1'
spec.add_dependency 'jekyll', '~> 3.3'
spec.add_development_dependency 'bundler', '~> 1.10'
spec.add_development_dependency 'rake', '~> 10.0'
spec.add_development_dependency 'rspec', '~> 3.3'

View File

@ -1,4 +1,3 @@
require "jekyll-seo-tag/filters"
require "jekyll-seo-tag/version"
module Jekyll
@ -42,7 +41,7 @@ module Jekyll
def info
{
:registers => context.registers,
:filters => [Jekyll::Filters, JekyllSeoTag::Filters]
:filters => [Jekyll::Filters]
}
end

View File

@ -1,13 +0,0 @@
module JekyllSeoTag
module Filters
# This is available in Liquid from version 3 which is required by Jekyll 3
# Provided here for compatibility with Jekyll 2.x
def default(input, default_value = "".freeze)
if !input || input.respond_to?(:empty?) && input.empty?
default_value
else
input
end
end
end
end

View File

@ -4,10 +4,6 @@
{% assign seo_homepage_or_about = true %}
{% endif %}
{% if site.url %}
{% assign seo_url = site.url | append: site.baseurl %}
{% endif %}
{% assign seo_url = seo_url | default: site.github.url %}
{% assign seo_site_title = site.title | default: site.name %}
{% if page.title %}
@ -87,7 +83,7 @@
{% if site.logo %}
{% assign seo_site_logo = site.logo %}
{% unless seo_site_logo contains "://" %}
{% assign seo_site_logo = seo_site_logo | prepend: seo_url %}
{% assign seo_site_logo = seo_site_logo | absolute_url %}
{% endunless %}
{% assign seo_site_logo = seo_site_logo | escape %}
{% endif %}
@ -95,7 +91,7 @@
{% if page.image %}
{% assign seo_page_image = page.image.path | default: page.image.facebook | default: page.image %}
{% unless seo_page_image contains "://" %}
{% assign seo_page_image = seo_page_image | prepend: seo_url %}
{% assign seo_page_image = seo_page_image | absolute_url %}
{% endunless %}
{% assign seo_page_image = seo_page_image | escape %}
{% endif %}
@ -113,9 +109,9 @@
<meta property="og:description" content="{{ seo_description }}" />
{% endif %}
{% if seo_url %}
<link rel="canonical" href="{{ page.url | prepend: seo_url | replace:'/index.html','/' }}" />
<meta property="og:url" content="{{ page.url | prepend: seo_url | replace:'/index.html','/' }}" />
{% if page.url %}
<link rel="canonical" href="{{ page.url | replace:'/index.html','/' | absolute_url }}" />
<meta property="og:url" content="{{ page.url | replace:'/index.html','/' | absolute_url }}" />
{% endif %}
{% if seo_site_title %}
@ -133,7 +129,7 @@
{% endif %}
{% if page.image.twitter %}
<meta name="twitter:image" content="{{ page.image.twitter | prepend: seo_url | escape }}" />
<meta name="twitter:image" content="{{ page.image.twitter | absolute_url }}" />
{% endif %}
{% if page.date %}
@ -142,10 +138,10 @@
{% endif %}
{% if paginator.previous_page %}
<link rel="prev" href="{{ paginator.previous_page_path | prepend: seo_url }}">
<link rel="prev" href="{{ paginator.previous_page_path | absolute_url }}">
{% endif %}
{% if paginator.next_page %}
<link rel="next" href="{{ paginator.next_page_path | prepend: seo_url }}">
<link rel="next" href="{{ paginator.next_page_path | absolute_url }}">
{% endif %}
{% if site.twitter %}
@ -216,7 +212,7 @@
"sameAs": {{ seo_links | jsonify }},
{% endif %}
"url": {{ page.url | prepend: seo_url | replace:'/index.html','/' | jsonify }}
"url": {{ page.url | replace:'/index.html','/' | absolute_url | jsonify }}
}
</script>

View File

@ -218,18 +218,6 @@ EOS
end
end
context "with site.github.url" do
let(:github_namespace) { { "url" => "http://example.invalid" } }
let(:site) { make_site("github" => github_namespace) }
it "uses site.github.url to build the seo url" do
expected = %r!<link rel="canonical" href="http://example.invalid/page.html" \/>!
expect(output).to match(expected)
expected = %r!<meta property="og:url" content="http://example.invalid/page.html" />!
expect(output).to match(expected)
end
end
context "posts" do
context "with post meta" do
let(:site) { make_site("url" => "http://example.invalid") }
@ -449,8 +437,8 @@ EOS
let(:context) { make_context({}, "paginator" => paginator) }
it "outputs pagination links" do
expect(output).to match(%r!<link rel="prev" href="foo">!)
expect(output).to match(%r!<link rel="next" href="bar">!)
expect(output).to match(%r!<link rel="prev" href="/foo">!)
expect(output).to match(%r!<link rel="next" href="/bar">!)
end
end
end

View File

@ -26,7 +26,7 @@ def make_page(options = {})
end
def make_post(options = {})
filename = File.expand_path("2015-01-01-post.md", CONFIG_DEFAULTS["source"])
filename = File.expand_path("_posts/2015-01-01-post.md", CONFIG_DEFAULTS["source"])
config = { :site => site, :collection => site.collections["posts"] }
page = Jekyll::Document.new filename, config
page.merge_data!(options)