From b675249b84e665237141b7d2eb81db8de367d374 Mon Sep 17 00:00:00 2001 From: Otavio Cordeiro Date: Mon, 1 Jan 2024 17:33:41 +0100 Subject: [PATCH] Only add values if present --- src/networking/NewPostRequest.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/networking/NewPostRequest.ts b/src/networking/NewPostRequest.ts index edf396b..705cdef 100644 --- a/src/networking/NewPostRequest.ts +++ b/src/networking/NewPostRequest.ts @@ -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[] } } @@ -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] } }