minify json ld and test

This commit is contained in:
Ben Balter 2016-02-25 13:56:13 -05:00
parent b77a20d3d9
commit 1e6b9e55e9
2 changed files with 23 additions and 1 deletions

View File

@ -5,7 +5,7 @@ module Jekyll
class SeoTag < Liquid::Tag
attr_accessor :context
MINIFY_REGEX = /(>\n|[%}]})\s+(<|{[{%])/
MINIFY_REGEX = /([>,]\n|[%}]})\s+?(<|{[{%]|[ ]+\")/
def initialize(_tag_name, text, _tokens)
super

View File

@ -133,6 +133,18 @@ describe Jekyll::SeoTag do
it 'outputs the site title meta' do
expect(output).to match(%r{<meta property="og:site_name" content="Foo" />})
end
it 'minifies the output' do
expected = <<-EOS
<!-- Begin Jekyll SEO tag v1.3.1 -->
<title>Foo</title>
<meta property="og:title" content="Foo" />
<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
expect(output).to match(expected)
end
end
end
@ -167,6 +179,16 @@ describe Jekyll::SeoTag do
expect(json_data['description']).to eql('description')
expect(json_data['image']).to eql('/img.png')
end
it 'minifies JSON-LD' do
expected = <<-EOS
{
"@context" : "http://schema.org",
"@type" : "BlogPosting",
"headline": "post",
EOS
expect(output).to match(expected)
end
end
end