Unverified Commit bbb8c67e authored by Paul Kaplan's avatar Paul Kaplan Committed by GitHub

Merge pull request #2448 from paulkaplan/metatags

Use custom meta tag info for project page.
parents 3cc6794c ef217b96
const React = require('react');
const Helmet = require('react-helmet').default;
const projectShape = require('./projectshape.jsx').projectShape;
const Meta = props => {
const {title, instructions, author} = props.projectInfo;
// Do not want to render any meta tags unless all the info is loaded
// Check only author (object) because it is ok to have empty string instructions
if (!author) return null;
const truncatedInstructions = instructions.split(' ')
.slice(0, 50)
.join(' ');
return (
<Helmet>
<title>{`${title} on Scratch`}</title>
<meta
content={`${title} on Scratch by ${author.username}`}
name="description"
/>
<meta
content={`Scratch - ${title}`}
property="og:title"
/>
<meta
content={truncatedInstructions}
property="og:description"
/>
</Helmet>
);
};
Meta.propTypes = {
projectInfo: projectShape
};
module.exports = Meta;
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment