Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
aav7fl authored Apr 4, 2017
2 parents 6009b49 + 271cba1 commit 9ec685a
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 15 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
/pkg/
/spec/reports/
/tmp/
/bin/
*.gem
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ 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
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,15 @@ webmaster_verifications:
yandex: 1234
```

* `lang` - The locale these tags are marked up in. Of the format `language_TERRITORY`. Default is `en_US`.

The SEO tag will respect the following YAML front matter if included in a post, page, or document:

* `title` - The title of the post, page, or document
* `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 below)
* `lang` - Page-, post-, or document-specific language information

## Advanced usage

Expand Down
6 changes: 0 additions & 6 deletions Rakefile

This file was deleted.

7 changes: 3 additions & 4 deletions jekyll-seo-tag.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ Gem::Specification.new do |spec|
spec.require_paths = ["lib"]

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"
spec.add_development_dependency "html-proofer", "~> 2.5"
spec.add_development_dependency "bundler", "~> 1.14"
spec.add_development_dependency "rspec", "~> 3.5"
spec.add_development_dependency "html-proofer", "~> 3.6"
spec.add_development_dependency "rubocop", "~> 0.48"
end
5 changes: 4 additions & 1 deletion lib/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@
{% assign seo_page_image = seo_page_image | escape %}
{% endif %}

{% assign seo_page_lang = page.lang | default: site.lang | default: "en_US" %}

{% if seo_tag.title and seo_title %}
<title>{{ seo_title }}</title>
{% endif %}
Expand All @@ -113,6 +115,8 @@
<meta name="author" content="{{ seo_author_name }}" />
{% endif %}

<meta property="og:locale" content="{{ seo_page_lang | replace:'-','_' }}" />

{% if seo_description %}
<meta name="description" content="{{ seo_description }}" />
<meta property="og:description" content="{{ seo_description }}" />
Expand All @@ -128,7 +132,6 @@
{% endif %}

{% if seo_page_image %}

<meta property="og:image" content="{{ seo_page_image }}" />
{% if page.image.height %}
<meta property="og:image:height" content="{{ page.image.height }}" />
Expand Down
2 changes: 1 addition & 1 deletion script/cibuild
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

set -ex

bundle exec rake spec
bundle exec rspec
bundle exec rubocop -S -D
bundle exec gem build jekyll-seo-tag.gemspec
37 changes: 36 additions & 1 deletion spec/jekyll_seo_tag_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
:check_html => true,
:checks_to_ignore => %w(ScriptCheck LinkCheck ImageCheck),
}
status = HTML::Proofer.new(dest_dir, options).run
status = HTMLProofer.check_directory(dest_dir, options).run
expect(status).to eql(true)
end

Expand Down Expand Up @@ -299,6 +299,7 @@
<!-- Begin Jekyll SEO tag v#{version} -->
<title>Foo</title>
<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" />
Expand Down Expand Up @@ -623,4 +624,38 @@
end
end
end

context "with locale" do
it "uses en_US when no locale is specified" do
expected = %r!<meta property="og:locale" content="en_US" />!
expect(output).to match(expected)
end

context "with site.lang" do
let(:site) { make_site("lang" => "en_US") }

it "uses site.lang if page.lang is not present" do
expected = %r!<meta property="og:locale" content="en_US" />!
expect(output).to match(expected)
end

context "with page.lang" do
let(:page) { make_page("lang" => "en_UK") }

it "uses page.lang if both site.lang and page.lang are present" do
expected = %r!<meta property="og:locale" content="en_UK" />!
expect(output).to match(expected)
end
end
end

context "with site.lang hyphenated" do
let(:site) { make_site("lang" => "en-US") }

it "coerces hyphen to underscore" do
expected = %r!<meta property="og:locale" content="en_US" />!
expect(output).to match(expected)
end
end
end
end
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
require "jekyll"
require "jekyll-seo-tag"
require "html/proofer"
require "html-proofer"

ENV["JEKYLL_LOG_LEVEL"] = "error"

Expand Down

0 comments on commit 9ec685a

Please sign in to comment.