Skip to content

Commit

Permalink
feat(frontend): add author and postDate to each job post
Browse files Browse the repository at this point in the history
  • Loading branch information
jerroydmoore committed Jan 3, 2020
1 parent 844b786 commit ae23387
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
21 changes: 18 additions & 3 deletions frontend/src/components/jobPost.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,26 @@ const JobPost = ({ job }) => {
<Card.Title>
<div dangerouslySetInnerHTML={{ __html: title }}></div>
</Card.Title>
{/* <Card.Text>
</Card.Text> */}
<Card.Text>
<div dangerouslySetInnerHTML={{ __html: body }}></div>
<small className="authorship">
Posted on{' '}
<a
title="View original post on Hacker News"
href={`https://news.ycombinator.com/item?id=${job.id}`}
rel="nofollow"
>
{job.postedDate.toLocaleString()}
</a>{' '}
by{' '}
<a
title="View author on Hacker News"
href={`https://news.ycombinator.com/user?id=${job.author}`}
rel="nofollow"
>
{job.author}
</a>
</small>
</Card.Text>
</Card.Body>
</Card>
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/components/layout.css
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ header {
margin-bottom: 1rem;
}

.job-posting .authorship {
color: #818181;
}
.postings-header {
margin-top: 3rem;
display: flex;
Expand Down
6 changes: 6 additions & 0 deletions frontend/src/services/jobPostings.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ export const latestMonth = new Date().toLocaleDateString('en-US', { month: 'long
let months = [];
const jobPostings = new Map();

function transformPost(post) {
post.postedDate = new Date(post.postedDate);
return post;
}
const getLatest = fetch(`${API_URI}/v1/whoishiring/latest`)
.then((response) => {
return response.json();
Expand All @@ -22,6 +26,7 @@ const getLatest = fetch(`${API_URI}/v1/whoishiring/latest`)
if (months[0] !== latestMonth) {
months.unshift(latestMonth);
}
results.posts = results.posts.map(transformPost);
return results;
})
.catch((err) => {
Expand All @@ -33,6 +38,7 @@ async function _getJobPostings(month) {
const response = await fetch(`${API_URI}/v1/whoishiring/months/${month}/posts`);
if (response.ok) {
const body = await response.json();
body.posts = body.posts.map(transformPost);
return body;
}
console.error(`fetch ${month} failed. status: ${response.status}. ${response.text}`);
Expand Down

0 comments on commit ae23387

Please sign in to comment.