Adding HTML lang attribute and description metadata

This commit is contained in:
Jeff Avallone
2019-01-16 06:35:43 -05:00
parent 325f01f034
commit c7ea0659f4
9 changed files with 64 additions and 19 deletions
+23 -9
View File
@@ -1,15 +1,29 @@
import React from 'react';
import PropTypes from 'prop-types';
import { withNamespaces } from 'react-i18next';
import { Helmet } from 'react-helmet';
const Metadata = ({ title }) => (
<Helmet>
<title>{ title ? `Regexper - ${ title }` : 'Regexper' }</title>
</Helmet>
);
class Metadata extends React.PureComponent {
static propTypes = {
title: PropTypes.string,
description: PropTypes.string,
i18n: PropTypes.shape({
language: PropTypes.string.isRequired
}).isRequired
}
Metadata.propTypes = {
title: PropTypes.string
};
render() {
const { title, description, i18n } = this.props;
const htmlAttributes = {
lang: i18n.language
};
export default Metadata;
return <Helmet htmlAttributes={ htmlAttributes }>
<title>{ title ? `Regexper - ${ title }` : 'Regexper' }</title>
{ description && <meta name="description" content={ description } /> }
</Helmet>;
}
}
export { Metadata };
export default withNamespaces()(Metadata);