{"size": 1564, "ext": "js", "max_stars_repo_path": "src/components/ArticleStructuredData.js", "max_stars_repo_name": "n1tranquilla/secret-uspoken-blog", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/components/ArticleStructuredData.js", "max_issues_repo_name": "n1tranquilla/secret-uspoken-blog", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/components/ArticleStructuredData.js", "max_forks_repo_name": "n1tranquilla/secret-uspoken-blog", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 28.962962963, "max_line_length": 67, "alphanum_fraction": 0.5748081841}
import React from 'react'
import PropTypes from 'prop-types'
import Helmet from 'react-helmet'
import moment from 'moment'

const ArticleStructuredData = props => {
    const { title, slug, author, description } = props 
    const { blogName, imgs, pubDate, modDate, siteUrl } = props
    const content=JSON.stringify({
        "@context": "http://schema.org",
        "@type": "NewsArticle",
        "mainEntityOfPage": {
            "@type": "WebPage",
            "@id": slug
        },
        "headline": title,
        "image": imgs,
        "datePublished": moment.utc(pubDate,"YYYY-MM-DD").format(),
        "dateModified": moment.utc(modDate,"YYYY-MM-DD").format(),
        "author": {
            "@type": "Person",
            "name": author
        },
        "publisher": {
            "@type": "Organization",
            "name": blogName,
            "logo":{
                "@type": "ImageObject",
                "url": `${siteUrl}/site-logo.png`
            }
        },
        "description": description
    })
    return (
        <Helmet>
            <script type="application/ld+json">{ content }</script>
        </Helmet>  
    )
}

const strType=PropTypes.string
ArticleStructuredData.propTypes={
    title: strType.isRequired,
    slug: strType.isRequired,
    author: strType.isRequired,
    description: strType.isRequired,
    blogName: strType.isRequired,
    imgs:PropTypes.arrayOf([strType]),
    pubDate: strType.isRequired,
    modDate: strType.isRequired,
    siteUrl: strType.isRequired
}

export default ArticleStructuredData