mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-29 13:52:10 +03:00
🐛 Fixed published time and modified time for structured data (#12085)
closes #12059 - Published Time and Modified Time were not populating for 'page' context because it is an extension of 'post' and hence there was no context 'page'. - Fixed it by using the common contextObject & `getContextObject` utility. - Should also fix some other missing parameters.
This commit is contained in:
parent
3430c47725
commit
c81d11b910
@ -1,16 +1,17 @@
|
||||
const urlService = require('../services/url');
|
||||
const getContextObject = require('./context_object.js');
|
||||
|
||||
function getAuthorUrl(data, absolute) {
|
||||
let context = data.context ? data.context[0] : null;
|
||||
|
||||
context = context === 'amp' ? 'post' : context;
|
||||
const contextObject = getContextObject(data, context);
|
||||
|
||||
if (data.author) {
|
||||
return urlService.getUrlByResourceId(data.author.id, {absolute: absolute, secure: data.author.secure, withSubdirectory: true});
|
||||
}
|
||||
|
||||
if (data[context] && data[context].primary_author) {
|
||||
return urlService.getUrlByResourceId(data[context].primary_author.id, {absolute: absolute, secure: data[context].secure, withSubdirectory: true});
|
||||
if (contextObject && contextObject.primary_author) {
|
||||
return urlService.getUrlByResourceId(contextObject.primary_author.id, {absolute: absolute, secure: contextObject.secure, withSubdirectory: true});
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -1,13 +1,13 @@
|
||||
const _ = require('lodash');
|
||||
const getContextObject = require('./context_object.js');
|
||||
|
||||
function getModifiedDate(data) {
|
||||
let context = data.context ? data.context : null;
|
||||
let modDate;
|
||||
|
||||
context = _.includes(context, 'amp') ? 'post' : context;
|
||||
const contextObject = getContextObject(data, context);
|
||||
|
||||
if (data[context]) {
|
||||
modDate = data[context].updated_at || null;
|
||||
if (contextObject) {
|
||||
modDate = contextObject.updated_at || null;
|
||||
if (modDate) {
|
||||
return new Date(modDate).toISOString();
|
||||
}
|
||||
|
@ -1,10 +1,12 @@
|
||||
const getContextObject = require('./context_object.js');
|
||||
|
||||
function getPublishedDate(data) {
|
||||
let context = data.context ? data.context[0] : null;
|
||||
|
||||
context = context === 'amp' ? 'post' : context;
|
||||
const contextObject = getContextObject(data, context);
|
||||
|
||||
if (data[context] && data[context].published_at) {
|
||||
return new Date(data[context].published_at).toISOString();
|
||||
if (contextObject && contextObject.published_at) {
|
||||
return new Date(contextObject.published_at).toISOString();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user