AllenYuan

http - articlepreview

Apr 23rd, 2020
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React from 'react';
  2.  
  3. const ArticlePreview = props => {
  4.   const article = props.article;
  5.  
  6.   return (
  7.     <div className="article-preview">
  8.       {/* article metadata */}
  9.       <div className="article-meta">
  10.         {/* author's avatar */}
  11.         <a>
  12.           <img src={article.author.image} />
  13.         </a>
  14.         {/* author username and creation date */}
  15.         <div className="info">
  16.           <a className="author">
  17.             {article.author.username}
  18.           </a>
  19.           <span className="date">
  20.             {new Date(article.createdAt).toDateString()}
  21.           </span>
  22.         </div>
  23.         {/* favorites button with a heart icon and a count next to it */}
  24.         <div className="pull-xs-right">
  25.           <button
  26.             className="btn btn-sm btn-outline-primary">
  27.             <i className="ion-heart"></i> {article.favoritesCount}
  28.           </button>
  29.         </div>
  30.       </div>
  31.  
  32.       {/* link to article with article's title, description, and list of tags */}
  33.       <a to={`article/${article.slug}`} className="preview-link">
  34.         <h1>{article.title}</h1>
  35.         <p>{article.description}</p>
  36.         <span>Read more...</span>
  37.         <ul className="tag-list">
  38.           {
  39.             article.tagList.map(tag => {
  40.               return (
  41.                 <li className="tag-default tag-pill tag-outline" key={tag}>
  42.                   {tag}
  43.                 </li>
  44.               )
  45.             })
  46.           }
  47.         </ul>
  48.       </a>
  49.     </div>
  50.   );
  51. }
  52.  
  53. export default ArticlePreview;
Advertisement
Add Comment
Please, Sign In to add comment