-
Notifications
You must be signed in to change notification settings - Fork 3
/
CourseItem.jsx
56 lines (45 loc) · 1.49 KB
/
CourseItem.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import React from 'react';
import PropTypes from 'prop-types';
import urlJoin from 'url-join';
import Author from './Author';
import play from '../assets/images/icons/icon_play.svg';
import clock from '../assets/images/icons/icon_clock.svg';
const dateOptions = {
year: 'numeric',
month: 'long',
day: 'numeric',
};
const authorRenderer = (author, index) => (
<Author author={author} key={index} />
);
const CourseItem = ({ course }) => {
const date = new Date(course.date);
return (
<article className="course-item">
<div className="course-item__heading">
<img className="course-item__icon" src={play} alt="" />
<div className="course-item__heading-right">
<img className="course-item__icon" src={clock} alt="" />
<p className="course-item__duration">{course.time} mins</p>
</div>
</div>
<div className="course-item__container">
<h2 className="course-item__title">
<a className="no-link-style" href={urlJoin('/course/', course.permalink)}>
{course.title}
</a>
</h2>
<p className="course-item__details">
<time dateTime={date.toISOString()}>{date.toLocaleString('fr-FR', dateOptions)}</time>
{' par '}
{course.authors.map(authorRenderer)}
</p>
<p className="course-item__description">{course.excerpt}</p>
</div>
</article>
);
};
CourseItem.propTypes = {
course: PropTypes.shape().isRequired,
};
export default CourseItem;