mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
Updated tags output serialiasation for v2 API
no-issue This ensures that the v2 API only outputs the tag properties we specify, and doesn't include any new fields, like the new metadata columns.
This commit is contained in:
parent
7e5292eccc
commit
a3f693b472
2 changed files with 32 additions and 14 deletions
|
@ -3,25 +3,43 @@ const localUtils = require('../../../index');
|
|||
|
||||
const tag = (attrs, frame) => {
|
||||
if (localUtils.isContentAPI(frame)) {
|
||||
delete attrs.created_at;
|
||||
delete attrs.updated_at;
|
||||
const contentAttrs = _.pick(attrs, [
|
||||
'description',
|
||||
'feature_image',
|
||||
'id',
|
||||
'meta_description',
|
||||
'meta_title',
|
||||
'name',
|
||||
'slug',
|
||||
'url',
|
||||
'visibility'
|
||||
]);
|
||||
|
||||
// We are standardising on returning null from the Content API for any empty values
|
||||
if (attrs.meta_title === '') {
|
||||
attrs.meta_title = null;
|
||||
if (contentAttrs.meta_title === '') {
|
||||
contentAttrs.meta_title = null;
|
||||
}
|
||||
if (attrs.meta_description === '') {
|
||||
attrs.meta_description = null;
|
||||
if (contentAttrs.meta_description === '') {
|
||||
contentAttrs.meta_description = null;
|
||||
}
|
||||
if (attrs.description === '') {
|
||||
attrs.description = null;
|
||||
if (contentAttrs.description === '') {
|
||||
contentAttrs.description = null;
|
||||
}
|
||||
}
|
||||
|
||||
delete attrs.parent_id;
|
||||
delete attrs.parent;
|
||||
|
||||
return attrs;
|
||||
return _.pick(attrs, [
|
||||
'created_at',
|
||||
'description',
|
||||
'feature_image',
|
||||
'id',
|
||||
'meta_description',
|
||||
'meta_title',
|
||||
'name',
|
||||
'slug',
|
||||
'updated_at',
|
||||
'url',
|
||||
'visibility'
|
||||
]);
|
||||
};
|
||||
|
||||
const author = (attrs, frame) => {
|
||||
|
|
|
@ -21,9 +21,9 @@ const mapTag = (model, frame) => {
|
|||
const jsonModel = model.toJSON ? model.toJSON(frame.options) : model;
|
||||
|
||||
url.forTag(model.id, jsonModel, frame.options);
|
||||
clean.tag(jsonModel, frame);
|
||||
const cleanedAttrs = clean.tag(jsonModel, frame);
|
||||
|
||||
return jsonModel;
|
||||
return cleanedAttrs;
|
||||
};
|
||||
|
||||
const mapPost = (model, frame) => {
|
||||
|
|
Loading…
Add table
Reference in a new issue