fix: improve SEO types

This commit is contained in:
Jean-Philippe Sirois
2019-07-27 17:32:39 -04:00
parent 22e4d68583
commit 04d0c19239
+21 -5
View File
@@ -3,13 +3,20 @@ import Helmet from "react-helmet"
import { useStaticQuery, graphql } from "gatsby" import { useStaticQuery, graphql } from "gatsby"
interface SEOProps { interface SEOProps {
readonly description: string readonly description?: string
readonly lang: string readonly lang?: string
readonly meta: object[] readonly meta?: any[]
readonly keywords?: string[]
readonly title: string readonly title: string
} }
const SEO = ({ description = "", lang = "en", meta = [], title }: SEOProps) => { const SEO = ({
description,
lang = "en",
meta = [],
keywords = [],
title,
}: SEOProps) => {
const { site } = useStaticQuery( const { site } = useStaticQuery(
graphql` graphql`
query { query {
@@ -66,7 +73,16 @@ const SEO = ({ description = "", lang = "en", meta = [], title }: SEOProps) => {
name: `twitter:description`, name: `twitter:description`,
content: metaDescription, content: metaDescription,
}, },
]} ]
.concat(
keywords.length > 0
? {
name: `keywords`,
content: keywords.join(`, `),
}
: []
)
.concat(meta)}
/> />
) )
} }