33import * as React from 'react'
44import Helmet from 'react-helmet'
55
6+ // keywords on every page.
7+ const keywordsBase = [
8+ 'bitcoin developer tools' ,
9+ 'bitcoin cash developer resource' ,
10+ 'bitcoin cash' ,
11+ 'BCH SDK' ,
12+ 'bitcoin sdk' ,
13+ 'bitcoin cash api' ,
14+ 'development tools' ,
15+ 'blockchain development' ,
16+ 'bitcoin development' ,
17+ 'bch developer' ,
18+ ]
19+
620type Props = {
721 title : string ,
822 description ?: string ,
923 image ?: string ,
10- keywords ?: string ,
11- location : { pathname : string } ,
24+ keywords ?: string [ ] ,
25+ location : { pathname : string , origin : string } ,
1226 children ?: React . Node ,
1327}
1428class HelmetPlus extends React . PureComponent < Props > {
29+ static defaultProps = {
30+ keywords : [ ] ,
31+ }
32+
1533 render ( ) {
1634 const {
1735 title ,
@@ -24,12 +42,21 @@ class HelmetPlus extends React.PureComponent<Props> {
2442
2543 return (
2644 < Helmet >
45+ { /* General tags */ }
46+ < meta charSet = "utf-8" />
2747 { title && < title > { title } </ title > }
2848 { description && < meta name = "description" content = { description } /> }
29- { keywords && < meta name = "keywords" content = { keywords } /> }
30- { image && < meta name = "image" content = { image } /> }
31-
32- { /* og meta */ }
49+ { keywords ? (
50+ < meta
51+ name = "keywords"
52+ content = { [ ...keywords , ...keywordsBase ] . join ( ', ' ) }
53+ />
54+ ) : (
55+ < meta name = "keywords" content = { keywordsBase . join ( ', ' ) } />
56+ ) }
57+ < meta name = "image" content = { `${ location . origin } /favicon.png` } /> }
58+ { image && < meta name = "image" content = { `${ location . origin } ${ image } ` } /> }
59+ { /* OpenGraph OG meta */ }
3360 { location && (
3461 < meta
3562 property = "og:url"
@@ -40,16 +67,21 @@ class HelmetPlus extends React.PureComponent<Props> {
4067 { description && (
4168 < meta property = "og:description" content = { description } />
4269 ) }
43- { image && < meta property = "og:image" content = { image } /> }
44-
70+ < meta name = "og:image" content = { `${ location . origin } /favicon.png` } /> }
71+ { image && (
72+ < meta property = "og:image" content = { `${ location . origin } ${ image } ` } />
73+ ) }
4574 { /* twitter meta */ }
4675 < meta name = "twitter:card" content = "summary" />
4776 { title && < meta name = "twitter:title" content = { title } /> }
4877 { description && (
4978 < meta name = "twitter:description" content = { description } />
5079 ) }
51- { image && < meta name = "twitter:image" content = { image } /> }
52-
80+ < meta name = "twitter:image" content = { `${ location . origin } /favicon.png` } />
81+ }
82+ { image && (
83+ < meta name = "twitter:image" content = { `${ location . origin } ${ image } ` } />
84+ ) }
5385 { children }
5486 </ Helmet >
5587 )
0 commit comments