mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
🐛 Updated v2 content API output to return null instead of “” for empty fields (#10378)
refs #10345 - We are standardising on returning null from the Content API for any empty values - Updated `post`, `tag` and `author` APIs
This commit is contained in:
parent
1a4497fc9a
commit
9d9690987a
1 changed files with 54 additions and 0 deletions
|
@ -7,6 +7,17 @@ const tag = (attrs) => {
|
|||
delete attrs.created_at;
|
||||
delete attrs.updated_at;
|
||||
|
||||
// We are standardising on returning null from the Content API for any empty values
|
||||
if (attrs.meta_title === '') {
|
||||
attrs.meta_title = null;
|
||||
}
|
||||
if (attrs.meta_description === '') {
|
||||
attrs.meta_description = null;
|
||||
}
|
||||
if (attrs.description === '') {
|
||||
attrs.description = null;
|
||||
}
|
||||
|
||||
return attrs;
|
||||
};
|
||||
|
||||
|
@ -24,6 +35,29 @@ const author = (attrs) => {
|
|||
delete attrs.tour;
|
||||
delete attrs.visibility;
|
||||
|
||||
// We are standardising on returning null from the Content API for any empty values
|
||||
if (attrs.twitter === '') {
|
||||
attrs.twitter = null;
|
||||
}
|
||||
if (attrs.bio === '') {
|
||||
attrs.bio = null;
|
||||
}
|
||||
if (attrs.website === '') {
|
||||
attrs.website = null;
|
||||
}
|
||||
if (attrs.facebook === '') {
|
||||
attrs.facebook = null;
|
||||
}
|
||||
if (attrs.meta_title === '') {
|
||||
attrs.meta_title = null;
|
||||
}
|
||||
if (attrs.meta_description === '') {
|
||||
attrs.meta_description = null;
|
||||
}
|
||||
if (attrs.location === '') {
|
||||
attrs.location = null;
|
||||
}
|
||||
|
||||
return attrs;
|
||||
};
|
||||
|
||||
|
@ -37,6 +71,26 @@ const post = (attrs) => {
|
|||
delete attrs.status;
|
||||
delete attrs.visibility;
|
||||
|
||||
// We are standardising on returning null from the Content API for any empty values
|
||||
if (attrs.twitter_title === '') {
|
||||
attrs.twitter_title = null;
|
||||
}
|
||||
if (attrs.twitter_description === '') {
|
||||
attrs.twitter_description = null;
|
||||
}
|
||||
if (attrs.meta_title === '') {
|
||||
attrs.meta_title = null;
|
||||
}
|
||||
if (attrs.meta_description === '') {
|
||||
attrs.meta_description = null;
|
||||
}
|
||||
if (attrs.og_title === '') {
|
||||
attrs.og_title = null;
|
||||
}
|
||||
if (attrs.og_description === '') {
|
||||
attrs.og_description = null;
|
||||
}
|
||||
|
||||
return attrs;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue