minify json ld and test
This commit is contained in:
parent
b77a20d3d9
commit
1e6b9e55e9
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue