-
Notifications
You must be signed in to change notification settings - Fork 50
/
Comment.js
64 lines (58 loc) · 1.43 KB
/
Comment.js
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
57
58
59
60
61
62
63
64
import styles from '@/styles/Illust.scss';
import React from 'react';
import PropTypes from 'prop-types';
import CSSModules from 'react-css-modules';
import Img from 'react-image';
import ListItem from 'react-mdl/lib/List/ListItem';
import ListItemContent from 'react-mdl/lib/List/ListItemContent';
import EmojiParser from '@/utils/EmojiParser';
const Comment = ({ item }) => {
for (const badWord of Comment.badWords) {
if (
typeof item.comment === 'string' &&
item.comment.toLowerCase().indexOf(badWord.toLowerCase()) > -1
) {
return null;
}
}
return (
<ListItem>
<ListItemContent
avatar={
<div>
<Img
src={[item.user.profile_image_urls.medium]}
loader={
<img src="data:image/gif;base64,R0lGODdhAQABAPAAAMPDwwAAACwAAAAAAQABAAACAkQBADs=" />
}
/>
</div>
}>
{item.user.name}
<span
styleName="comment-content"
dangerouslySetInnerHTML={{
__html: EmojiParser.parse(item.comment)
}}
/>
</ListItemContent>
</ListItem>
);
};
Comment.badWords = [
'墙',
'VPN',
'登上了',
'http',
'hosts',
'科学上网',
'撕逼',
'好酸',
'醋意',
'P站'
];
Comment.propTypes = {
item: PropTypes.object
};
// eslint-disable-next-line babel/new-cap
export default CSSModules(Comment, styles, { allowMultiple: true });