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");