diff --git a/src/components/Footer/__snapshots__/test.js.snap b/src/components/Footer/__snapshots__/test.js.snap
index 70d1a8c..a11faa4 100644
--- a/src/components/Footer/__snapshots__/test.js.snap
+++ b/src/components/Footer/__snapshots__/test.js.snap
@@ -4,7 +4,13 @@ exports[`Footer rendering 1`] = `
ShallowWrapper {
Symbol(enzyme.__root__): [Circular],
Symbol(enzyme.__unrendered__): ,
Symbol(enzyme.__renderer__): Object {
diff --git a/src/components/Footer/index.js b/src/components/Footer/index.js
index 3a6a742..7c0c9de 100644
--- a/src/components/Footer/index.js
+++ b/src/components/Footer/index.js
@@ -1,10 +1,8 @@
import React from 'react';
import PropTypes from 'prop-types';
-import { graphql } from 'gatsby';
+import { StaticQuery, graphql } from 'gatsby';
import { withNamespaces, Trans } from 'react-i18next';
-import withQuery from 'lib/with-query';
-
import style from './style.module.css';
const query = graphql`
@@ -17,7 +15,7 @@ const query = graphql`
}
`;
-export const Footer = ({ t, buildId }) => (
+export const Footer = ({ t, site: { siteMetadata } }) => (
);
Footer.propTypes = {
t: PropTypes.func.isRequired,
- buildId: PropTypes.string.isRequired
+ site: PropTypes.shape({
+ siteMetadata: PropTypes.shape({
+ buildId: PropTypes.string.isRequired
+ }).isRequired
+ }).isRequired
};
-export default [
- withQuery(query, {
- toProps: ({ site: { siteMetadata } }) => siteMetadata
- }),
- withNamespaces()
-].reduce((component, fn) => fn(component), Footer);
+export default withNamespaces()(props => (
+ (
+
+ ) } />
+));
diff --git a/src/components/Footer/test.js b/src/components/Footer/test.js
index e681fc2..47e0071 100644
--- a/src/components/Footer/test.js
+++ b/src/components/Footer/test.js
@@ -7,7 +7,7 @@ import { Footer } from 'components/Footer';
describe('Footer', () => {
test('rendering', () => {
const component = shallow(
-
+
);
expect(component).toMatchSnapshot();
});
diff --git a/src/components/Header/__snapshots__/test.js.snap b/src/components/Header/__snapshots__/test.js.snap
index 15475cf..52e7a4e 100644
--- a/src/components/Header/__snapshots__/test.js.snap
+++ b/src/components/Header/__snapshots__/test.js.snap
@@ -4,7 +4,13 @@ exports[`Header rendering 1`] = `
ShallowWrapper {
Symbol(enzyme.__root__): [Circular],
Symbol(enzyme.__unrendered__): ,
Symbol(enzyme.__renderer__): Object {
"batchedUpdates": [Function],
@@ -534,7 +540,13 @@ exports[`Header rendering with no banner 1`] = `
ShallowWrapper {
Symbol(enzyme.__root__): [Circular],
Symbol(enzyme.__unrendered__): ,
Symbol(enzyme.__renderer__): Object {
"batchedUpdates": [Function],
diff --git a/src/components/Header/index.js b/src/components/Header/index.js
index c193747..9f637e7 100644
--- a/src/components/Header/index.js
+++ b/src/components/Header/index.js
@@ -1,11 +1,10 @@
import React from 'react';
import PropTypes from 'prop-types';
-import { Link, graphql } from 'gatsby';
+import { Link, StaticQuery, graphql } from 'gatsby';
import { withNamespaces, Trans } from 'react-i18next';
import GitlabIcon from 'react-feather/dist/icons/gitlab';
-import withQuery from 'lib/with-query';
import LocaleSwitcher from 'components/LocaleSwitcher';
import style from './style.module.css';
@@ -20,10 +19,10 @@ const query = graphql`
}
`;
-export const Header = ({ banner }) => (
+export const Header = ({ site: { siteMetadata } }) => (
+ data-banner={ siteMetadata.banner || null }>
Regexper
@@ -50,15 +49,18 @@ export const Header = ({ banner }) => (
);
Header.propTypes = {
- banner: PropTypes.oneOfType([
- PropTypes.bool,
- PropTypes.string
- ]).isRequired
+ site: PropTypes.shape({
+ siteMetadata: PropTypes.shape({
+ banner: PropTypes.oneOfType([
+ PropTypes.bool,
+ PropTypes.string
+ ]).isRequired
+ }).isRequired
+ }).isRequired
};
-export default [
- withQuery(query, {
- toProps: ({ site: { siteMetadata } }) => siteMetadata
- }),
- withNamespaces()
-].reduce((component, fn) => fn(component), Header);
+export default withNamespaces()(props => (
+ (
+
+ ) } />
+));
diff --git a/src/components/Header/test.js b/src/components/Header/test.js
index 7d64c25..f4c3dca 100644
--- a/src/components/Header/test.js
+++ b/src/components/Header/test.js
@@ -6,14 +6,14 @@ import { Header } from 'components/Header';
describe('Header', () => {
test('rendering', () => {
const component = shallow(
-
+
);
expect(component).toMatchSnapshot();
});
test('rendering with no banner', () => {
const component = shallow(
-
+
);
expect(component).toMatchSnapshot();
});
diff --git a/src/components/Layout/__snapshots__/test.js.snap b/src/components/Layout/__snapshots__/test.js.snap
index da64f63..8ceef60 100644
--- a/src/components/Layout/__snapshots__/test.js.snap
+++ b/src/components/Layout/__snapshots__/test.js.snap
@@ -20,11 +20,11 @@ ShallowWrapper {
"nodeType": "class",
"props": Object {
"children": Array [
- ,
+ ,
Example content
,
- ,
+ ,
],
},
"ref": null,
@@ -68,11 +68,11 @@ ShallowWrapper {
"nodeType": "class",
"props": Object {
"children": Array [
- ,
+ ,
Example content
,
- ,
+ ,
],
},
"ref": null,
diff --git a/src/lib/with-query.js b/src/lib/with-query.js
deleted file mode 100644
index 5f613eb..0000000
--- a/src/lib/with-query.js
+++ /dev/null
@@ -1,21 +0,0 @@
-import React from 'react';
-import { StaticQuery } from 'gatsby';
-
-const withQuery = (query, options = {}) => Component => {
- const { toProps } = {
- toProps: data => data,
- ...options
- };
- const displayName = Component.displayName || Component.name || 'Component';
- const wrapped = props => (
- (
-
- ) } />
- );
-
- wrapped.displayName = `WithQuery(${ displayName })`;
-
- return wrapped;
-};
-
-export default withQuery;