From 206e717bae8db7171b1bdf8896f15a2debb2f433 Mon Sep 17 00:00:00 2001 From: PigeonsHouse Date: Wed, 6 Dec 2023 22:46:28 +0900 Subject: [PATCH] =?UTF-8?q?update:=20=E5=85=AC=E9=96=8B=E6=99=82=E5=88=BB?= =?UTF-8?q?=E3=81=AE=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/toybox.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/utils/toybox.js b/utils/toybox.js index 17cff61..e2a8481 100644 --- a/utils/toybox.js +++ b/utils/toybox.js @@ -9,6 +9,17 @@ export function formatToybox(blog) { }, } }) + const createdAt = blog.published_at + ? new Date(blog.created_at) < new Date(blog.published_at) + ? blog.published_at + : blog.created_at + : blog.created_at + const updatedAt = blog.published_at + ? new Date(blog.updated_at) < new Date(blog.published_at) + ? blog.published_at + : blog.updated_at + : blog.updated_at + return { fields: { body: blog.body_text, @@ -42,8 +53,8 @@ export function formatToybox(blog) { }, sys: { id: blog.id, - createdAt: blog.created_at, - updatedAt: blog.updated_at, + createdAt, + updatedAt, }, } }