From 6fc1ebb09df138f8c3a4c0ee39cb8160eb96c573 Mon Sep 17 00:00:00 2001 From: Arjun Komath Date: Thu, 2 Jan 2025 21:52:46 +1100 Subject: [PATCH] Add tags support to new post action and handle backward compatibility --- .../api/integrations/github/action-new-post.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/apps/web/pages/api/integrations/github/action-new-post.tsx b/apps/web/pages/api/integrations/github/action-new-post.tsx index 1ef739b..74327d9 100644 --- a/apps/web/pages/api/integrations/github/action-new-post.tsx +++ b/apps/web/pages/api/integrations/github/action-new-post.tsx @@ -12,11 +12,17 @@ export default async function handler( res: NextApiResponse | null | IErrorResponse> ) { const { - body: { title, type, content, status }, + body: { title, type, tags, content, status }, } = req; const page_secret_key = req.headers["page-secret-key"]; - if (!page_secret_key || !title || !type || !content || !status) { + if (!page_secret_key || !title || !content || !status) { + res + .status(400) + .json({ error: { statusCode: 400, message: "Invalid request" } }); + } + + if (!tags && !type) { res .status(400) .json({ error: { statusCode: 400, message: "Invalid request" } }); @@ -34,7 +40,7 @@ export default async function handler( page_id: pageDetails.id, title, content, - type, + tags: tags ?? [type], status, images_folder: v4(), publication_date: