From 04d0c19239ae57d790bcdd1a9bb9146f3a12eb9c Mon Sep 17 00:00:00 2001 From: Jean-Philippe Sirois Date: Sat, 27 Jul 2019 16:53:49 -0400 Subject: [PATCH] fix: improve SEO types --- src/components/SEO/index.tsx | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/components/SEO/index.tsx b/src/components/SEO/index.tsx index cf51443..1384238 100644 --- a/src/components/SEO/index.tsx +++ b/src/components/SEO/index.tsx @@ -3,13 +3,20 @@ import Helmet from "react-helmet" import { useStaticQuery, graphql } from "gatsby" interface SEOProps { - readonly description: string - readonly lang: string - readonly meta: object[] + readonly description?: string + readonly lang?: string + readonly meta?: any[] + readonly keywords?: string[] readonly title: string } -const SEO = ({ description = "", lang = "en", meta = [], title }: SEOProps) => { +const SEO = ({ + description, + lang = "en", + meta = [], + keywords = [], + title, +}: SEOProps) => { const { site } = useStaticQuery( graphql` query { @@ -66,7 +73,16 @@ const SEO = ({ description = "", lang = "en", meta = [], title }: SEOProps) => { name: `twitter:description`, content: metaDescription, }, - ]} + ] + .concat( + keywords.length > 0 + ? { + name: `keywords`, + content: keywords.join(`, `), + } + : [] + ) + .concat(meta)} /> ) }