Ghost/core/frontend/meta/published_date.js
Roshan Dash c81d11b910
🐛 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.
2020-08-17 15:52:31 +01:00

15 lines
393 B
JavaScript

const getContextObject = require('./context_object.js');
function getPublishedDate(data) {
let context = data.context ? data.context[0] : null;
const contextObject = getContextObject(data, context);
if (contextObject && contextObject.published_at) {
return new Date(contextObject.published_at).toISOString();
}
return null;
}
module.exports = getPublishedDate;