From 34090dcd8ad38707a74d1761fc4f1b7b23d0b211 Mon Sep 17 00:00:00 2001 From: wotnak Date: Wed, 9 Aug 2023 13:10:47 +0200 Subject: [PATCH] feat: make social links configuration optional (#84) --- packages/gatsby-theme-adr/gatsby-node.js | 24 +++++++++++++++++++ .../src/components/layout/Footer.tsx | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/packages/gatsby-theme-adr/gatsby-node.js b/packages/gatsby-theme-adr/gatsby-node.js index f894a8f..5d11800 100644 --- a/packages/gatsby-theme-adr/gatsby-node.js +++ b/packages/gatsby-theme-adr/gatsby-node.js @@ -145,3 +145,27 @@ exports.createPages = async ({ graphql, actions, reporter }) => { createAdrDetail(createPage, graphql, reporter), ]); }; + +// Define SiteMetadata type schema to allow for optional socialLinks. +exports.createSchemaCustomization = ({ actions }) => { + actions.createTypes(` + type Site { + siteMetadata: SiteMetadata! + } + + type SiteMetadata { + siteUrl: String! + title: String! + description: String! + image: String! + menuLinks: [IconLink!]! + socialLinks: [IconLink!] + } + + type IconLink { + name: String! + uri: String! + iconName: String + } + `); +}; diff --git a/packages/gatsby-theme-adr/src/components/layout/Footer.tsx b/packages/gatsby-theme-adr/src/components/layout/Footer.tsx index b61c737..66f281c 100644 --- a/packages/gatsby-theme-adr/src/components/layout/Footer.tsx +++ b/packages/gatsby-theme-adr/src/components/layout/Footer.tsx @@ -26,7 +26,7 @@ const Footer = ({ links, socialLinks }: FooterProps): ReactElement => { ))}
- {socialLinks.map(({ name, uri, iconName }) => { + {socialLinks?.map(({ name, uri, iconName }) => { return ( {name}