@@ -4,7 +4,7 @@ import { Helmet } from 'react-helmet'
44import { useLocation } from '@reach/router'
55import { useStaticQuery , graphql } from 'gatsby'
66
7- const SEO = ( { title, description, image, article } ) => {
7+ const SEO = ( { title, description, name , image, article } ) => {
88 const { pathname } = useLocation ( )
99 const { site } = useStaticQuery ( query )
1010
@@ -20,6 +20,7 @@ const SEO = ({ title, description, image, article }) => {
2020 const seo = {
2121 title : title || defaultTitle ,
2222 description : description || defaultDescription ,
23+ name : name ,
2324 image : `${ siteUrl } ${ image || defaultImage } ` ,
2425 url : `${ siteUrl } ${ pathname } ` ,
2526 }
@@ -29,7 +30,7 @@ const SEO = ({ title, description, image, article }) => {
2930 < meta name = "description" content = { seo . description } />
3031 < meta name = "image" content = { seo . image } />
3132
32- { seo . url && < meta property = "og:url" content = { seo . url } /> }
33+ { seo . url && < meta property = "og:url" content = { seo . url . replace ( 'docs//' , 'docs/' ) } /> }
3334
3435 { ( article ? true : null ) && < meta property = "og:type" content = "article" /> }
3536
@@ -48,6 +49,26 @@ const SEO = ({ title, description, image, article }) => {
4849 { seo . description && < meta name = "twitter:description" content = { seo . description } /> }
4950
5051 { seo . image && < meta name = "twitter:image" content = { seo . image } /> }
52+
53+ { seo . name && (
54+ < script type = "application/ld+json" >
55+ { `
56+ "@context": "https://schema.org",
57+ "@type": "BreadcrumbList",
58+ "itemListElement": [{
59+ "@type": "ListItem",
60+ "position": 1,
61+ "name": "React",
62+ "item": "${ siteUrl } "
63+ },{
64+ "@type": "ListItem",
65+ "position": 2,
66+ "name": "${ seo . name } ",
67+ "item": "${ seo . url . replace ( 'docs//' , 'docs/' ) } "
68+ }]
69+ ` }
70+ </ script >
71+ ) }
5172 </ Helmet >
5273 )
5374}
@@ -57,13 +78,15 @@ export default SEO
5778SEO . propTypes = {
5879 title : PropTypes . string ,
5980 description : PropTypes . string ,
81+ name : PropTypes . string ,
6082 image : PropTypes . string ,
6183 article : PropTypes . bool ,
6284}
6385
6486SEO . defaultProps = {
6587 title : null ,
6688 description : null ,
89+ name : null ,
6790 image : null ,
6891 article : false ,
6992}
0 commit comments