Simplifying html tags code.

This commit is contained in:
Dessalines 2020-12-15 18:34:14 -06:00
parent 222c9cee1d
commit 6ffe0c530d

View file

@ -17,39 +17,29 @@ export class HtmlTags extends Component<HtmlTagsProps, any> {
return ( return (
<Helmet title={this.props.title}> <Helmet title={this.props.title}>
{/* Primary Meta Tags */} {['title', 'og:title', 'twitter:title'].map(t => (
<meta name="title" content={this.props.title} /> <meta property={t} content={this.props.title} />
))}
{['og:url', 'twitter:url'].map(u => (
<meta property={u} content={url} />
))}
{/* Open Graph / Facebook */} {/* Open Graph / Facebook */}
<meta property="og:type" content="website" /> <meta property="og:type" content="website" />
<meta property="og:url" content={url} />
<meta property="og:title" content={this.props.title} />
{/* Twitter */} {/* Twitter */}
<meta property="twitter:card" content="summary_large_image" /> <meta property="twitter:card" content="summary_large_image" />
<meta property="twitter:url" content={url} />
<meta property="twitter:title" content={this.props.title} />
{/* Optional desc and images */} {/* Optional desc and images */}
{this.props.description && [ {this.props.description &&
<meta ['description', 'og:description', 'twitter:description'].map(n => (
name="description" <meta name={n} content={md.renderInline(this.props.description)} />
content={md.renderInline(this.props.description)} ))}
/>,
<meta
property="og:description"
content={md.renderInline(this.props.description)}
/>,
<meta
property="twitter:description"
content={md.renderInline(this.props.description)}
/>,
]}
{this.props.image && [ {this.props.image &&
<meta property="og:image" content={this.props.image} />, ['og:image', 'twitter:image'].map(p => (
<meta property="twitter:image" content={this.props.image} />, <meta property={p} content={this.props.image} />
]} ))}
</Helmet> </Helmet>
); );
} }