-
Notifications
You must be signed in to change notification settings - Fork 10.3k
/
seo.js
45 lines (40 loc) · 1.22 KB
/
seo.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/**
* SEO component that queries for data with
* Gatsby's useStaticQuery React hook
*
* See: https://www.gatsbyjs.com/docs/how-to/querying-data/use-static-query/
*/
import * as React from "react"
import { useStaticQuery, graphql } from "gatsby"
function Seo({ description, title, children }) {
const { site } = useStaticQuery(
graphql`
query {
site {
siteMetadata {
title
description
author
}
}
}
`
)
const metaDescription = description || site.siteMetadata.description
const defaultTitle = site.siteMetadata?.title
return (
<>
<title>{defaultTitle ? `${title} | ${defaultTitle}` : title}</title>
<meta name="description" content={metaDescription} />
<meta property="og:title" content={title} />
<meta property="og:description" content={metaDescription} />
<meta property="og:type" content="website" />
<meta name="twitter:card" content="summary" />
<meta name="twitter:creator" content={site.siteMetadata?.author || ``} />
<meta name="twitter:title" content={title} />
<meta name="twitter:description" content={metaDescription} />
{children}
</>
)
}
export default Seo