From 6dd5f0fd30cc9f1bb595d47d5cb50a9579417c07 Mon Sep 17 00:00:00 2001 From: Takanori Oishi Date: Sun, 3 Nov 2024 13:11:50 +0900 Subject: [PATCH] update --- gatsby-node.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gatsby-node.ts b/gatsby-node.ts index aefbd5c5..a3d0138a 100644 --- a/gatsby-node.ts +++ b/gatsby-node.ts @@ -203,9 +203,13 @@ export const createSchemaCustomization: GatsbyNode["createSchemaCustomization"] */ export const onCreateNode: GatsbyNode["onCreateNode"] = ({ node, actions }) => { const { createNodeField } = actions; - const date = node.date ?? (node.frontmatter as Record).date; + const date = + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- date is nullable + node?.date ?? (node?.frontmatter as Record)?.date; + const endDate = - node.endDate ?? (node.frontmatter as Record).endDate; + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- endDate is nullable + node?.endDate ?? (node?.frontmatter as Record)?.endDate; if (typeof date === "string" || date instanceof Date) { const dateYear = formatInTimeZone(date, "Asia/Tokyo", "yyyy");