-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Content tags point player, team or game if applicable
- Loading branch information
1 parent
096adf4
commit ef9facd
Showing
5 changed files
with
62 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import React from 'react'; | ||
import { PropTypes } from 'prop-types'; | ||
import Link from 'next/link'; | ||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; | ||
import { faHockeyPuck, faPeopleGroup, faTag, faUser } from '@fortawesome/free-solid-svg-icons'; | ||
|
||
const ContentTag = ({ tag }) => { | ||
let url = `/news/topic/${tag.slug}`; | ||
let icon = faTag; | ||
|
||
if (tag.externalSourceName === 'player') { | ||
url = `/player/${tag.extraData.playerId}`; | ||
icon = faUser; | ||
} | ||
|
||
if (tag.externalSourceName === 'team') { | ||
url = `/team/${tag.extraData.abbreviation}`; | ||
icon = faPeopleGroup; | ||
} | ||
|
||
if (tag.externalSourceName === 'game') { | ||
url = `/game/${tag.extraData.gameId}`; | ||
icon = faHockeyPuck; | ||
} | ||
|
||
return ( | ||
<Link href={url} key={tag._entityId} className="inline-block rounded p-1 border text-xs m-1"> | ||
<FontAwesomeIcon icon={icon} fixedWidth className="mr-1" /> {tag.title} | ||
</Link> | ||
); | ||
}; | ||
|
||
ContentTag.propTypes = { | ||
tag: PropTypes.shape({ | ||
_entityId: PropTypes.string.isRequired, | ||
extraData: PropTypes.object, | ||
externalSourceName: PropTypes.string, | ||
slug: PropTypes.string.isRequired, | ||
title: PropTypes.string.isRequired, | ||
}).isRequired, | ||
}; | ||
|
||
export default ContentTag; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters