mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 05:37:34 +03:00
🐛 Fixed 404 in collection index page if using data.slug
closes #10542 - Fixed error that was causing collection index to not be rendered: relations connected to alliased resource were not fetched
This commit is contained in:
parent
17cc70b94b
commit
f5c1ed8fcb
@ -28,6 +28,13 @@ const defaultQueryOptions = {
|
||||
}
|
||||
};
|
||||
|
||||
const defaultDataQueryOptions = {
|
||||
post: _.cloneDeep(defaultQueryOptions),
|
||||
page: _.cloneDeep(defaultQueryOptions),
|
||||
tag: null,
|
||||
author: null
|
||||
};
|
||||
|
||||
const defaultPostQuery = _.cloneDeep(queryDefaults);
|
||||
defaultPostQuery.options = defaultQueryOptions.options;
|
||||
|
||||
@ -97,7 +104,8 @@ function fetchData(pathOptions, routerOptions, locals) {
|
||||
|
||||
// CASE: fetch more data defined by the router e.g. tags, authors - see TaxonomyRouter
|
||||
_.each(routerOptions.data, function (query, name) {
|
||||
props[name] = processQuery(query, pathOptions.slug, locals);
|
||||
const dataQueryOptions = _.merge(query, defaultDataQueryOptions[name]);
|
||||
props[name] = processQuery(dataQueryOptions, pathOptions.slug, locals);
|
||||
});
|
||||
|
||||
return Promise.props(props)
|
||||
|
@ -102,6 +102,106 @@ describe('getSchema', function () {
|
||||
done();
|
||||
});
|
||||
|
||||
it('should return page schema if context starts with page', function (done) {
|
||||
var metadata = {
|
||||
blog: {
|
||||
title: 'Blog Title',
|
||||
url: 'http://mysite.com',
|
||||
logo: {
|
||||
url: 'http://mysite.com/author/image/url/logo.jpg',
|
||||
dimensions: {
|
||||
width: 500,
|
||||
height: 500
|
||||
}
|
||||
}
|
||||
},
|
||||
authorImage: {
|
||||
url: 'http://mysite.com/author/image/url/me.jpg',
|
||||
dimensions: {
|
||||
width: 500,
|
||||
height: 500
|
||||
}
|
||||
},
|
||||
authorFacebook: 'testuser',
|
||||
creatorTwitter: '@testuser',
|
||||
authorUrl: 'http://mysite.com/author/me/',
|
||||
metaTitle: 'Page Title',
|
||||
url: 'http://mysite.com/post/my-page-slug/',
|
||||
publishedDate: '2015-12-25T05:35:01.234Z',
|
||||
modifiedDate: '2016-01-21T22:13:05.412Z',
|
||||
coverImage: {
|
||||
url: 'http://mysite.com/content/image/mypagecoverimage.jpg',
|
||||
dimensions: {
|
||||
width: 500,
|
||||
height: 500
|
||||
}
|
||||
},
|
||||
keywords: ['one', 'two'],
|
||||
metaDescription: 'Post meta description',
|
||||
excerpt: 'Custom excerpt for description'
|
||||
}, data = {
|
||||
context: ['page'],
|
||||
page: {
|
||||
primary_author: {
|
||||
name: 'Page Author',
|
||||
website: 'http://myblogsite.com/',
|
||||
bio: 'My author bio.',
|
||||
facebook: 'testuser',
|
||||
twitter: '@testuser'
|
||||
}
|
||||
}
|
||||
},
|
||||
schema = getSchema(metadata, data);
|
||||
|
||||
should.deepEqual(schema, {
|
||||
'@context': 'https://schema.org',
|
||||
'@type': 'Article',
|
||||
author: {
|
||||
'@type': 'Person',
|
||||
image: {
|
||||
'@type': 'ImageObject',
|
||||
url: 'http://mysite.com/author/image/url/me.jpg',
|
||||
width: 500,
|
||||
height: 500
|
||||
},
|
||||
name: 'Page Author',
|
||||
sameAs: [
|
||||
'http://myblogsite.com/',
|
||||
'https://www.facebook.com/testuser',
|
||||
'https://twitter.com/testuser'
|
||||
],
|
||||
url: 'http://mysite.com/author/me/'
|
||||
},
|
||||
dateModified: '2016-01-21T22:13:05.412Z',
|
||||
datePublished: '2015-12-25T05:35:01.234Z',
|
||||
description: 'Custom excerpt for description',
|
||||
headline: 'Page Title',
|
||||
image: {
|
||||
'@type': 'ImageObject',
|
||||
url: 'http://mysite.com/content/image/mypagecoverimage.jpg',
|
||||
width: 500,
|
||||
height: 500
|
||||
},
|
||||
keywords: 'one, two',
|
||||
mainEntityOfPage: {
|
||||
'@type': 'WebPage',
|
||||
'@id': 'http://mysite.com'
|
||||
},
|
||||
publisher: {
|
||||
'@type': 'Organization',
|
||||
name: 'Blog Title',
|
||||
logo: {
|
||||
'@type': 'ImageObject',
|
||||
url: 'http://mysite.com/author/image/url/logo.jpg',
|
||||
width: 500,
|
||||
height: 500
|
||||
}
|
||||
},
|
||||
url: 'http://mysite.com/post/my-page-slug/'
|
||||
});
|
||||
done();
|
||||
});
|
||||
|
||||
it('should return post schema if context starts with amp', function (done) {
|
||||
var metadata = {
|
||||
blog: {
|
||||
|
Loading…
Reference in New Issue
Block a user