Skip to content

Commit

Permalink
Only add values if present
Browse files Browse the repository at this point in the history
  • Loading branch information
otaviocc committed Jan 1, 2024
1 parent e4bc9f4 commit b675249
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/networking/NewPostRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
* Definition of the JSON used to create a post.
*/
export type NewPostRequest = {
'type': [string]
'mp-destination': string
'type': string[]
'mp-destination'?: string
'properties': {
"name": string[]
"name"?: string[]
'content': string[],
'category': string[],
'published': [string],
'post-status': [string]
'published'?: string[],
'post-status': string[]
}
}

Expand All @@ -24,12 +24,12 @@ export function makeNewPostRequest(
): NewPostRequest {
return {
'type': ["h-entry"],
'mp-destination': blogID,
...blogID.length > 0 && blogID !== 'default' && { 'mp-destination': blogID },
'properties': {
"name": [title],
...title.length > 0 && { "name": [title] },
'content': [content],
'category': categories,
'published': [published],
...published.length > 0 && { 'published': [published] },
'post-status': [postStatus]
}
}
Expand Down

0 comments on commit b675249

Please sign in to comment.