Merge pull request #6616 from ErisDS/meta-schema-fix

Never output null JSON-LD schema
This commit is contained in:
Sebastian Gierlinger 2016-03-21 10:22:06 +01:00
commit 1256272640
2 changed files with 25 additions and 3 deletions

View File

@ -103,10 +103,12 @@ function ghost_head(options) {
head.push.apply(head, finaliseStructuredData(metaData));
head.push('');
if (metaData.schema) {
head.push('<script type="application/ld+json">\n' +
JSON.stringify(metaData.schema, null, ' ') +
'\n </script>\n');
}
}
if (client && client.id && client.secret) {
head.push(getAjaxHelper(client.id, client.secret));

View File

@ -595,6 +595,26 @@ describe('{{ghost_head}} helper', function () {
}).catch(done);
});
it('outputs structured data but not schema for custom channel', function (done) {
helpers.ghost_head.call(
{safeVersion: '0.3', relativeUrl: '/featured/', context: ['featured']},
{data: {root: {context: ['featured']}}}
).then(function (rendered) {
should.exist(rendered);
rendered.string.should.match(/<link rel="canonical" href="http:\/\/testurl.com\/featured\/" \/>/);
rendered.string.should.match(/<meta name="generator" content="Ghost 0.3" \/>/);
rendered.string.should.match(/<link rel="alternate" type="application\/rss\+xml" title="Ghost" href="http:\/\/testurl.com\/rss\/" \/>/);
rendered.string.should.match(/<meta property="og:site_name" content="Ghost" \/>/);
rendered.string.should.match(/<meta property="og:type" content="website" \/>/);
rendered.string.should.match(/<meta property="og:title" content="Ghost" \/>/);
rendered.string.should.match(/<meta property="og:url" content="http:\/\/testurl.com\/featured\/" \/>/);
rendered.string.should.not.match(/<script type=\"application\/ld\+json\">/);
done();
}).catch(done);
});
it('returns twitter and facebook descriptions if no meta description available', function (done) {
var post = {
title: 'Welcome to Ghost',