forked from JustComments/gatsby-plugin-just-comments
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
33 lines (28 loc) · 722 Bytes
/
index.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
const React = require('react');
class JustComments extends React.Component {
constructor(...args) {
super(...args);
this.ref = React.createRef();
}
render() {
return React.createElement('div', {
className: 'just-comments',
ref: this.ref,
...this.getProps(),
});
}
getProps() {
const keys = Object.keys(this.props);
const props = keys.reduce((props, key) => {
props[`data-${key.toLowerCase()}`] = this.props[key];
return props;
}, {});
return props;
}
componentDidMount() {
const s = document.createElement('script');
s.src = 'https://just-comments.com/w.js';
this.ref.current.appendChild(s);
}
}
module.exports = JustComments;