Skip to content

Instantly share code, notes, and snippets.

@Tin-Nguyen
Created April 14, 2017 02:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tin-Nguyen/9157d27f90a0c71f554c54a611a0e2a7 to your computer and use it in GitHub Desktop.
Save Tin-Nguyen/9157d27f90a0c71f554c54a611a0e2a7 to your computer and use it in GitHub Desktop.
const LatestPostsComponent = props => {
const postPreviews = renderPostPreviews(props.posts);
return (
<section>
<div><h1>Latest posts</h1></div>
<div>
{ postPreviews }
</div>
</section>
);
};
const renderPostPreviews = posts => (
posts.map(post => this.renderPostPreview(post))
);
const renderPostPreview = post => (
<article>
<h3><a href={`/post/${post.slug}`}>{post.title}</a></h3>
<time pubdate><em>{post.posted}</em></time>
<div>
<span>{post.blurb}</span>
<a href={`/post/${post.slug}`}>Read more...</a>
</div>
</article>
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment