From bac12ca88003898b77b3a1b51ef8008d34d87a48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20F=C3=BCl=C3=B6pp?= Date: Wed, 1 Dec 2021 23:25:30 +0100 Subject: [PATCH] RangeError: Invalid time value --- gatsby-node.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/gatsby-node.js b/gatsby-node.js index 6b8c3ee..cbca23b 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -111,14 +111,14 @@ exports.sourceNodes = async ( const tags = datum.tags ? Object.keys(datum.tags) : []; + const readDay = datum.time_read ? parseInt(format(startOfDay(new Date(parseInt(datum.time_read) * 1000)), "X")) : 0 + + const readWeek = datum.time_read ? parseInt(format(startOfWeek(new Date(parseInt(datum.time_read) * 1000)), "X")) : 0 + createNode({ id: createNodeId(`${POCKET_ARTICLE_NODE_TYPE}-${datum.item_id}`), - readDay: parseInt( - format(startOfDay(new Date(parseInt(datum.time_read) * 1000)), "X") - ), - readWeek: parseInt( - format(startOfWeek(new Date(parseInt(datum.time_read) * 1000)), "X") - ), + readDay: readDay, + readWeek: readWeek, url: datum.resolved_url, title: datum.resolved_title, articleDomain: articleDomain,