|
| 1 | +import React from 'react' |
| 2 | +import { Helmet } from 'react-helmet' |
| 3 | +import config from '../config' |
| 4 | + |
| 5 | +type Props = { |
| 6 | + title?: string |
| 7 | + description?: string |
| 8 | + img?: string |
| 9 | +} |
| 10 | + |
| 11 | +const SEO = ({ title, description, img }: Props) => ( |
| 12 | + <Helmet |
| 13 | + title={title || config.title} |
| 14 | + meta={[ |
| 15 | + { |
| 16 | + name: 'description', |
| 17 | + content: `${description || config.description}`, |
| 18 | + }, |
| 19 | + |
| 20 | + { property: 'og:type', content: config.ogType }, |
| 21 | + { |
| 22 | + property: 'og:title', |
| 23 | + content: `${title || config.title}`, |
| 24 | + }, |
| 25 | + { |
| 26 | + property: 'og:description', |
| 27 | + content: `${description || config.description}`, |
| 28 | + }, |
| 29 | + { |
| 30 | + property: 'og:url', |
| 31 | + content: `${config.siteUrl}`, |
| 32 | + }, |
| 33 | + { |
| 34 | + property: 'og:site_name', |
| 35 | + content: `${title || config.title}`, |
| 36 | + }, |
| 37 | + { |
| 38 | + property: 'article:section', |
| 39 | + content: config.title, |
| 40 | + }, |
| 41 | + { property: 'og:image:type', content: config.ogImgType }, |
| 42 | + { property: 'og:image:width', content: config.ogImgWidth }, |
| 43 | + { property: 'og:image:height', content: config.ogImgHeight }, |
| 44 | + { |
| 45 | + property: 'og:image', |
| 46 | + content: `${img || config.featuredImage}`, |
| 47 | + }, |
| 48 | + { |
| 49 | + property: 'og:image:secure_url', |
| 50 | + content: `${img || config.featuredImage}`, |
| 51 | + }, |
| 52 | + { |
| 53 | + property: 'article:author', |
| 54 | + content: config.facebook, |
| 55 | + }, |
| 56 | + { |
| 57 | + property: 'article:publisher', |
| 58 | + content: config.facebook, |
| 59 | + }, |
| 60 | + { |
| 61 | + name: 'twitter:url', |
| 62 | + content: `${config.siteUrl}`, |
| 63 | + }, |
| 64 | + { |
| 65 | + name: 'twitter:creator', |
| 66 | + content: config.twitter, |
| 67 | + }, |
| 68 | + { |
| 69 | + name: 'twitter:site', |
| 70 | + content: config.twitter, |
| 71 | + }, |
| 72 | + { |
| 73 | + name: 'twitter:title', |
| 74 | + content: `${title || config.title}`, |
| 75 | + }, |
| 76 | + { |
| 77 | + name: 'twitter:card', |
| 78 | + content: config.twitterCard, |
| 79 | + }, |
| 80 | + { |
| 81 | + name: 'twitter:image', |
| 82 | + content: `${img || config.featuredImage}`, |
| 83 | + }, |
| 84 | + { |
| 85 | + name: 'twitter:image:alt', |
| 86 | + content: config.twitterImgAlt, |
| 87 | + }, |
| 88 | + { |
| 89 | + name: 'twitter:description', |
| 90 | + content: `${description || config.description}`, |
| 91 | + }, |
| 92 | + ]} |
| 93 | + > |
| 94 | + <html lang={config.lang} /> |
| 95 | + </Helmet> |
| 96 | +) |
| 97 | + |
| 98 | +export default SEO |
0 commit comments