info line adjustments.
This commit is contained in:
parent
72e2232469
commit
8bb2d174bf
|
@ -13,16 +13,46 @@ export const sourceLink = (story) => {
|
|||
);
|
||||
};
|
||||
|
||||
export const storyScore = story => {
|
||||
if (!story.score) {
|
||||
return null;
|
||||
}
|
||||
return (<>{story.score} points</>);
|
||||
};
|
||||
export const storyAuthor = story => {
|
||||
if (!story.author) {
|
||||
return null;
|
||||
}
|
||||
if (story.author_link) {
|
||||
return (<>by <a href={story.author_link}>{story.author}</a></>);
|
||||
}
|
||||
return <>by {story.author}</>;
|
||||
};
|
||||
|
||||
export const storyCommentsLink = story => {
|
||||
if (!story.num_comments) {
|
||||
return null;
|
||||
}
|
||||
return (<Link
|
||||
className={story.num_comments > 99 ? "hot" : ""}
|
||||
to={"/" + story.id + "/c"}>
|
||||
{story.num_comments} comment{story.num_comments !== 1 && "s"}
|
||||
</Link>);
|
||||
};
|
||||
|
||||
export const infoLine = (story) => (
|
||||
<div className="info">
|
||||
{story.score} points by {story.author_link ? <a href={story.author_link}>{story.author}</a> : story.author}
|
||||
​ {moment.unix(story.date).fromNow()}
|
||||
​ on <a href={story.link}>{story.source}</a> | ​
|
||||
<Link
|
||||
className={story.num_comments > 99 ? "hot" : ""}
|
||||
to={"/" + story.id + "/c"}>
|
||||
{story.num_comments} comment{story.num_comments !== 1 && "s"}
|
||||
</Link>
|
||||
{[
|
||||
<>{moment.unix(story.date).fromNow()} {storyAuthor(story)}</>,
|
||||
<><a href={story.link}>{story.source}</a></>,
|
||||
storyScore(story),/*​*/
|
||||
storyCommentsLink(story)
|
||||
].filter(e => e).map((e, i) => (
|
||||
<>
|
||||
{i !== 0 ? <> • </> : <></>}
|
||||
{e}
|
||||
</>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user