Merge pull request #162 from jhabdas/moz-separator
Update title separator. Closes #121
This commit is contained in:
commit
4aedc4f7e3
|
@ -8,7 +8,7 @@ A Jekyll plugin to add metadata tags for search engines and social networks to b
|
|||
|
||||
Jekyll SEO Tag adds the following meta tags to your site:
|
||||
|
||||
* Pages title (with site title appended when available)
|
||||
* Page title, with site title or description appended
|
||||
* Page description
|
||||
* Canonical URL
|
||||
* Next and previous URLs on paginated pages
|
||||
|
|
|
@ -5,21 +5,13 @@
|
|||
{% endif %}
|
||||
|
||||
{% assign seo_site_title = site.title | default: site.name %}
|
||||
{% assign seo_page_title = page.title | default: seo_site_title %}
|
||||
{% assign seo_title = page.title | default: seo_site_title %}
|
||||
|
||||
{% if page.title %}
|
||||
{% assign seo_title = page.title %}
|
||||
{% assign seo_page_title = page.title %}
|
||||
|
||||
{% if seo_site_title %}
|
||||
{% assign seo_title = seo_title | append:" - " | append: seo_site_title %}
|
||||
{% endif %}
|
||||
{% elsif seo_site_title %}
|
||||
{% assign seo_title = seo_site_title %}
|
||||
{% assign seo_page_title = seo_site_title %}
|
||||
|
||||
{% if site.description %}
|
||||
{% assign seo_title = seo_title | append:" - " | append: site.description %}
|
||||
{% endif %}
|
||||
{% if page.title and seo_site_title %}
|
||||
{% assign seo_title = page.title | append:" | " | append: seo_site_title %}
|
||||
{% elsif site.description and seo_site_title %}
|
||||
{% assign seo_title = seo_site_title | append:" | " | append: site.description %}
|
||||
{% endif %}
|
||||
|
||||
{% if page.seo and page.seo.name %}
|
||||
|
|
|
@ -44,11 +44,51 @@ describe Jekyll::SeoTag do
|
|||
expect(output).to match(expected)
|
||||
end
|
||||
|
||||
context "with site.name" do
|
||||
let(:site) { make_site("name" => "Site Name") }
|
||||
|
||||
it "builds the title with a page title and site name" do
|
||||
expect(output).to match(%r!<title>foo \| Site Name</title>!)
|
||||
end
|
||||
end
|
||||
|
||||
context "with site.title" do
|
||||
let(:site) { make_site("title" => "bar") }
|
||||
|
||||
it "builds the title with a page title and site title" do
|
||||
expect(output).to match(%r!<title>foo - bar</title>!)
|
||||
expect(output).to match(%r!<title>foo \| bar</title>!)
|
||||
end
|
||||
end
|
||||
|
||||
context "with site.description" do
|
||||
let(:site) { make_site("description" => "Site Description") }
|
||||
|
||||
it "builds the title without the site description" do
|
||||
expect(output).not_to match(%r!<title>foo \| Site Description</title>!)
|
||||
end
|
||||
end
|
||||
|
||||
context "with site.title and site.description" do
|
||||
let(:site) { make_site("title" => "Site Title", "description" => "Site Description") }
|
||||
|
||||
it "builds the title with a page title and site title" do
|
||||
expect(output).to match(%r!<title>foo \| Site Title</title>!)
|
||||
end
|
||||
|
||||
it "does not build the title with the site description" do
|
||||
expect(output).not_to match(%r!<title>foo \| Site Description</title>!)
|
||||
end
|
||||
end
|
||||
|
||||
context "with site.title and site.description" do
|
||||
let(:site) { make_site("title" => "Site Title", "description" => "Site Description") }
|
||||
|
||||
it "builds the title with a page title and site title" do
|
||||
expect(output).to match(%r!<title>foo \| Site Title</title>!)
|
||||
end
|
||||
|
||||
it "does not build the title with the site description" do
|
||||
expect(output).not_to match(%r!<title>Page Title \| Site Description</title>!)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -61,6 +101,14 @@ describe Jekyll::SeoTag do
|
|||
end
|
||||
end
|
||||
|
||||
context "with site.title and site.description" do
|
||||
let(:site) { make_site("title" => "Site Title", "description" => "Site Description") }
|
||||
|
||||
it "builds the title with site title and description" do
|
||||
expect(output).to match(%r!<title>Site Title \| Site Description</title>!)
|
||||
end
|
||||
end
|
||||
|
||||
context "with page.description" do
|
||||
let(:page) { make_page("description" => "foo") }
|
||||
|
||||
|
|
Loading…
Reference in New Issue