Skip to content
This repository has been archived by the owner on Apr 9, 2023. It is now read-only.

Commit

Permalink
feature: add user molecule meta component
Browse files Browse the repository at this point in the history
  • Loading branch information
byCedric committed Oct 14, 2018
1 parent 6e516f7 commit e366549
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/molecules/user/user-meta.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React from 'react';
import PropTypes from 'prop-types';
import Helmet from 'react-helmet';
import { findMentions } from 'src/providers/github';

export default function UserMoleculeMeta(props) {
const title = props.description
? `${props.title}${props.description}`
: props.title;

const keywords = props.description
? props.keywords.concat(findMentions(props.description))
: props.keywords;

return (
<Helmet>
<title>{title}</title>
<meta name="description" content={props.description} />
<meta name="keywords" content={keywords.join(', ')} />
</Helmet>
);
}

UserMoleculeMeta.propTypes = {
/** The full page title to use. */
title: PropTypes.string.isRequired,
/** A list of all keywords of this person, in relevant order. */
keywords: PropTypes.arrayOf(PropTypes.string),
/** An optional description of this person. */
description: PropTypes.string,
};

UserMoleculeMeta.defaultProps = {
keywords: [],
description: '',
};
6 changes: 6 additions & 0 deletions src/molecules/user/user.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import Avatar from 'src/atoms/avatar';
import UserMeta from './user-meta';
import {
UserContainer,
UserAvatar,
Expand All @@ -13,6 +14,11 @@ export default function UserMolecule(props) {

return (
<UserContainer>
<UserMeta
title={identifier}
description={props.description}
keywords={[props.name, props.username]}
/>
<UserAvatar>
<Avatar
url={props.avatarUrl}
Expand Down

0 comments on commit e366549

Please sign in to comment.