Skip to content

Instantly share code, notes, and snippets.

@villanuevawill
Created October 9, 2018 00:46
Show Gist options
  • Save villanuevawill/d00ef4ceecc02eccbe91b5666d52d350 to your computer and use it in GitHub Desktop.
Save villanuevawill/d00ef4ceecc02eccbe91b5666d52d350 to your computer and use it in GitHub Desktop.
Bounty metatags
import React from 'react';
import { Helmet } from 'react-helmet';
import { EXPIRED } from 'public-modules/Bounty/constants';
import moment from 'moment';
const SEOHeader = props => {
const { bounty } = props;
if (!bounty) {
return null;
}
const description = bounty.description
.replace('# Description', '')
.substring(0, 199);
const fulfillmentAmount = Number(bounty.calculated_fulfillmentAmount).toFixed(
2
);
const usdPrice = Number(bounty.usd_price).toFixed(2);
const value = `${fulfillmentAmount} ${bounty.tokenSymbol} ($${usdPrice} USD)`;
const deadline = moment
.utc(bounty.deadline, 'YYYY-MM-DDThh:mm:ssZ')
.fromNow(true);
const deadlineDescription =
bounty.bountyStage === EXPIRED ? 'expired' : 'remaining';
const deadlineText = `${deadline} ${deadlineDescription}`;
return (
<Helmet>
<title>{bounty.title}</title>
<meta name="description" content={description} />
<meta name="twitter:card" value="summary_large_image" />
<meta name="twitter:site" content="@ethbounties" />
<meta name="twitter:title" content={bounty.title} />
<meta name="twitter:description" content={description} />
<meta name="twitter:creator" content="@ethbounties" />
<meta name="twitter:image:src" content={bounty.image_preview} />
<meta name="twitter:label1" value="Bounty Payout" />
<meta name="twitter:data1" value={value} />
<meta name="twitter:label2" value="Deadline to Submit" />
<meta name="twitter:data2" value={deadlineText} />
<meta property="og:title" content={bounty.title} />
<meta property="og:type" content="article" />
<meta property="og:url" content={window.location.href} />
<meta property="og:image:secure_url" content={bounty.image_preview} />
<meta property="og:description" content={description} />
</Helmet>
);
};
export default SEOHeader;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment