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