mirror of
https://github.com/mastermindzh/rickvanlieshout.com
synced 2025-09-20 07:00:26 +02:00
Upgrade to Gatsby v2
This commit is contained in:
37
src/components/Post/Comments/Comments.js
Normal file
37
src/components/Post/Comments/Comments.js
Normal file
@@ -0,0 +1,37 @@
|
||||
import React from 'react';
|
||||
import { graphql, StaticQuery } from 'gatsby';
|
||||
import ReactDisqusComments from 'react-disqus-comments';
|
||||
|
||||
export const PureComments = ({ data, postTitle, postSlug }) => {
|
||||
const {
|
||||
siteUrl,
|
||||
disqusShortname
|
||||
} = data.site.siteMetadata;
|
||||
|
||||
return (
|
||||
<ReactDisqusComments
|
||||
shortname={disqusShortname}
|
||||
identifier={postTitle}
|
||||
title={postTitle}
|
||||
url={siteUrl + postSlug}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export const Comments = (props) => (
|
||||
<StaticQuery
|
||||
query={graphql`
|
||||
query CommentsQuery {
|
||||
site {
|
||||
siteMetadata {
|
||||
disqusShortname
|
||||
url
|
||||
}
|
||||
}
|
||||
}
|
||||
`}
|
||||
render={(data) => <PureComments {...props} data={data}/>}
|
||||
/>
|
||||
);
|
||||
|
||||
export default Comments;
|
23
src/components/Post/Comments/Comments.test.js
Normal file
23
src/components/Post/Comments/Comments.test.js
Normal file
@@ -0,0 +1,23 @@
|
||||
import React from 'react';
|
||||
import renderer from 'react-test-renderer';
|
||||
import { PureComments as Comments } from './Comments';
|
||||
|
||||
describe('Comments', () => {
|
||||
it('renders correctly', () => {
|
||||
const props = {
|
||||
data: {
|
||||
site: {
|
||||
siteMetadata: {
|
||||
url: 'http://localhost',
|
||||
disqusShortname: 'test'
|
||||
}
|
||||
}
|
||||
},
|
||||
postTitle: 'test',
|
||||
postSlug: '/test'
|
||||
};
|
||||
|
||||
const tree = renderer.create(<Comments {...props} />).toJSON();
|
||||
expect(tree).toMatchSnapshot();
|
||||
});
|
||||
});
|
@@ -0,0 +1,9 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Comments renders correctly 1`] = `
|
||||
<div>
|
||||
<div
|
||||
id="disqus_thread"
|
||||
/>
|
||||
</div>
|
||||
`;
|
1
src/components/Post/Comments/index.js
Normal file
1
src/components/Post/Comments/index.js
Normal file
@@ -0,0 +1 @@
|
||||
export { default } from './Comments';
|
Reference in New Issue
Block a user