Upgrade to Gatsby v2

This commit is contained in:
alxshelepenok
2018-11-09 20:08:48 +03:00
parent e83dfc6dff
commit 8b92891329
204 changed files with 18708 additions and 3904 deletions

View 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;

View 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();
});
});

View File

@@ -0,0 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Comments renders correctly 1`] = `
<div>
<div
id="disqus_thread"
/>
</div>
`;

View File

@@ -0,0 +1 @@
export { default } from './Comments';