Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React from 'react';
- const ArticlePreview = props => {
- const article = props.article;
- return (
- <div className="article-preview">
- {/* article metadata */}
- <div className="article-meta">
- {/* author's avatar */}
- <a>
- <img src={article.author.image} />
- </a>
- {/* author username and creation date */}
- <div className="info">
- <a className="author">
- {article.author.username}
- </a>
- <span className="date">
- {new Date(article.createdAt).toDateString()}
- </span>
- </div>
- {/* favorites button with a heart icon and a count next to it */}
- <div className="pull-xs-right">
- <button
- className="btn btn-sm btn-outline-primary">
- <i className="ion-heart"></i> {article.favoritesCount}
- </button>
- </div>
- </div>
- {/* link to article with article's title, description, and list of tags */}
- <a to={`article/${article.slug}`} className="preview-link">
- <h1>{article.title}</h1>
- <p>{article.description}</p>
- <span>Read more...</span>
- <ul className="tag-list">
- {
- article.tagList.map(tag => {
- return (
- <li className="tag-default tag-pill tag-outline" key={tag}>
- {tag}
- </li>
- )
- })
- }
- </ul>
- </a>
- </div>
- );
- }
- export default ArticlePreview;
Advertisement
Add Comment
Please, Sign In to add comment