mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-29 15:12:58 +03:00
Merge pull request #6616 from ErisDS/meta-schema-fix
Never output null JSON-LD schema
This commit is contained in:
commit
1256272640
@ -103,9 +103,11 @@ function ghost_head(options) {
|
||||
head.push.apply(head, finaliseStructuredData(metaData));
|
||||
head.push('');
|
||||
|
||||
head.push('<script type="application/ld+json">\n' +
|
||||
JSON.stringify(metaData.schema, null, ' ') +
|
||||
'\n </script>\n');
|
||||
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) {
|
||||
|
@ -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',
|
||||
|
Loading…
Reference in New Issue
Block a user