Merge pull request #237 from jekyll/unified-bass-drop

Pass the unified drop to the template rather than an ad-hoc payload
This commit is contained in:
Frank Taillandier 2017-09-06 21:37:45 +02:00 committed by GitHub
commit 7313ee7e50
4 changed files with 54 additions and 8 deletions

View File

@ -44,12 +44,12 @@ 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],
"site" => context.registers[:site].site_payload["site"],
"paginator" => context["paginator"],
"seo_tag" => drop,
}
})
end
def drop

View File

@ -20,10 +20,6 @@ module Jekyll
Jekyll::SeoTag::VERSION
end
def jekyll_version
Jekyll::VERSION
end
# Should the `<title>` tag be generated for this page?
def title?
return false unless title

View File

@ -3,7 +3,7 @@
<title>{{ seo_tag.title }}</title>
{% endif %}
<meta name="generator" content="Jekyll v{{ seo_tag.jekyll_version }}" />
<meta name="generator" content="Jekyll v{{ jekyll.version }}" />
{% if seo_tag.page_title %}
<meta property="og:title" content="{{ seo_tag.page_title }}" />

View File

@ -0,0 +1,50 @@
RSpec.describe Jekyll::SeoTag do
let(:config) { { "title" => "site title" } }
let(:page_meta) { {} }
let(:page) { make_page(page_meta) }
let(:site) { make_site(config) }
let(:render_context) { make_context(:page => page, :site => site) }
let(:text) { "" }
let(:tag_name) { "github_edit_link" }
let(:tokenizer) { Liquid::Tokenizer.new("") }
let(:parse_context) { Liquid::ParseContext.new }
let(:rendered) { subject.render(render_context) }
let(:payload) { subject.send(:payload) }
subject do
tag = described_class.parse(tag_name, text, tokenizer, parse_context)
tag.instance_variable_set("@context", render_context)
tag
end
before do
Jekyll.logger.log_level = :error
end
it "returns the template" do
expect(described_class.template).to be_a(Liquid::Template)
end
context "payload" do
it "contains the drop" do
expect(payload["seo_tag"]).to be_a(Jekyll::SeoTag::Drop)
end
it "contains the Jekyll drop" do
expect(payload["jekyll"]).to be_a(Jekyll::Drops::JekyllDrop)
end
it "contains the page" do
expect(payload["page"]).to be_a(Jekyll::Page)
end
it "contains the site" do
expect(payload["site"]).to be_a(Jekyll::Drops::SiteDrop)
end
end
it "renders" do
expected = "<!-- Begin Jekyll SEO tag v#{described_class::VERSION} -->"
expect(rendered).to match(expected)
end
end