|
1 | 1 | import React from "react";
|
2 | 2 | import { format, parseISO } from "date-fns";
|
3 |
| -import slugify from "slugify"; |
4 |
| - |
5 |
| -import parseHtml from "../../../scripts/parse-html"; |
6 | 3 |
|
7 | 4 | const formatPostDate = (post) =>
|
8 | 5 | format(parseISO(post.frontmatter.date), "MMMM d, yyyy");
|
9 | 6 |
|
10 |
| -const PostCard = ({ post, full }) => { |
| 7 | +const PostCard = ({ post }) => { |
11 | 8 | const categories = post.frontmatter.categories || [];
|
12 |
| - const { hasPreview, previewHtml, mainHtml, previewDescription } = |
13 |
| - parseHtml(post); |
14 | 9 |
|
15 |
| - const html = full ? mainHtml : hasPreview ? previewHtml : previewDescription; |
16 | 10 | const url =
|
17 | 11 | post.frontmatter.externalUrl !== "" ? post.frontmatter.externalUrl : null;
|
18 | 12 |
|
19 | 13 | return (
|
20 | 14 | <div className='blog-post-card' key={post.id}>
|
21 |
| - <a |
22 |
| - className='blog-title-link' |
23 |
| - href={url || post.frontmatter.path} |
24 |
| - target={url ? "_blank" : null} |
25 |
| - rel={url ? "noopener noreferrer" : null} |
26 |
| - > |
27 |
| - <h3 className='blog-title'>{post.frontmatter.title}</h3> |
28 |
| - </a> |
29 |
| - <div className='blog-post-card-container'> |
| 15 | + {post.frontmatter.ogImage && <img className="post-image" src={post.frontmatter.ogImage.publicURL} width="300" height="220"/>} |
| 16 | + {!post.frontmatter.ogImage && <img className="post-image" src='/images/placeholder-cover.jpg' width="300" height="220"/>} |
| 17 | + <div className="blog-post-card-content"> |
30 | 18 | <a
|
31 |
| - className='blog-link' |
| 19 | + className='blog-title-link' |
32 | 20 | href={url || post.frontmatter.path}
|
33 | 21 | target={url ? "_blank" : null}
|
34 | 22 | rel={url ? "noopener noreferrer" : null}
|
35 | 23 | >
|
36 |
| - Read more |
37 |
| - <span className='link-triangle' /> |
| 24 | + <h3 className='blog-title'>{post.frontmatter.title}</h3> |
38 | 25 | </a>
|
39 |
| - <div className='blog-categories-and-date'> |
40 |
| - <span className='blog-date'>{formatPostDate(post)}</span> |
41 |
| - {categories.length > 0 && ( |
42 |
| - <div className='blog-post-categories'> |
43 |
| - {categories.map( |
44 |
| - (category, _) => |
45 |
| - category !== "_" && ( |
46 |
| - <span className='blog-post-category' key={category}> |
47 |
| - <a className="blog-post-category-link" href={`/blog/categories/${slugify(category, {lower: true})}`}> |
48 |
| - {category} |
49 |
| - </a> |
50 |
| - </span> |
51 |
| - ) |
52 |
| - )} |
53 |
| - {url && ( |
54 |
| - <span className='blog-post-category blog-post-category-link'> |
55 |
| - External |
56 |
| - </span> |
57 |
| - )} |
58 |
| - </div> |
59 |
| - )} |
| 26 | + <div className='blog-post-card-container'> |
| 27 | + <a |
| 28 | + className='blog-link' |
| 29 | + href={url || post.frontmatter.path} |
| 30 | + target={url ? "_blank" : null} |
| 31 | + rel={url ? "noopener noreferrer" : null} |
| 32 | + > |
| 33 | + Read more |
| 34 | + <span className='link-triangle' /> |
| 35 | + </a> |
| 36 | + <div className='blog-categories-and-date'> |
| 37 | + <span className='blog-date'>{formatPostDate(post)}</span> |
| 38 | + {categories.length > 0 && ( |
| 39 | + <div className='blog-post-categories'> |
| 40 | + {categories.map( |
| 41 | + (category, _) => |
| 42 | + category !== "_" && ( |
| 43 | + <span className='blog-post-category' key={category}> |
| 44 | + {category} |
| 45 | + </span> |
| 46 | + ) |
| 47 | + )} |
| 48 | + {url && ( |
| 49 | + <span className='blog-post-category'> |
| 50 | + External |
| 51 | + </span> |
| 52 | + )} |
| 53 | + </div> |
| 54 | + )} |
| 55 | + </div> |
60 | 56 | </div>
|
61 | 57 | </div>
|
62 |
| - <div |
63 |
| - className='blog-post-content' |
64 |
| - dangerouslySetInnerHTML={{ __html: html }} |
65 |
| - /> |
66 | 58 | </div>
|
67 | 59 | );
|
68 | 60 | };
|
|
0 commit comments