diff --git a/src/components/PageTemplate.js b/src/components/PageTemplate.js index ad00123..6da50db 100644 --- a/src/components/PageTemplate.js +++ b/src/components/PageTemplate.js @@ -1,4 +1,5 @@ import React from 'react'; +import ReactDOMServer from 'react-dom/server'; import PropTypes from 'prop-types'; import pkg from '../../package.json'; @@ -54,4 +55,7 @@ PageTemplate.propTypes = { children: PropTypes.element }; +const renderToString = content => '' + ReactDOMServer.renderToString(content); + export default PageTemplate; +export { renderToString }; diff --git a/src/pages/404.js b/src/pages/404.js deleted file mode 100644 index 3fa24fd..0000000 --- a/src/pages/404.js +++ /dev/null @@ -1,13 +0,0 @@ -import React from 'react'; -import ReactDOM from 'react-dom'; - -import '../style.css'; - -import Message from '../components/Message'; -import ErrorIcon from 'feather-icons/dist/icons/alert-octagon.svg'; - -ReactDOM.render( - -

The page you have requested could not be found

-
, - document.getElementById('root')); diff --git a/src/pages/404/index.js b/src/pages/404/index.js new file mode 100644 index 0000000..999e117 --- /dev/null +++ b/src/pages/404/index.js @@ -0,0 +1 @@ +import '../../style.css'; diff --git a/src/pages/404/template.js b/src/pages/404/template.js new file mode 100644 index 0000000..fc19d1d --- /dev/null +++ b/src/pages/404/template.js @@ -0,0 +1,14 @@ +import 'babel-register'; +import React from 'react'; + +import PageTemplate, { renderToString } from '../../components/PageTemplate'; +import Message from '../../components/Message'; +import AlertIcon from 'feather-icons/dist/icons/alert-octagon.svg'; + +export default renderToString( + + +

The page you have requested could not be found

+
+
+); diff --git a/src/pages/index.js b/src/pages/index/index.js similarity index 55% rename from src/pages/index.js rename to src/pages/index/index.js index 69defc8..444cfb0 100644 --- a/src/pages/index.js +++ b/src/pages/index/index.js @@ -1,9 +1,9 @@ import React from 'react'; import ReactDOM from 'react-dom'; -import App from '../components/App'; +import App from '../../components/App'; -import '../style.css'; -import '../service-worker'; +import '../../style.css'; +import '../../service-worker'; ReactDOM.render(, document.getElementById('root')); diff --git a/src/template.js b/src/pages/index/template.js similarity index 83% rename from src/template.js rename to src/pages/index/template.js index 2928159..80ecf34 100644 --- a/src/template.js +++ b/src/pages/index/template.js @@ -1,12 +1,11 @@ import 'babel-register'; import React from 'react'; -import ReactDOMServer from 'react-dom/server'; -import PageTemplate from './components/PageTemplate'; -import Message from './components/Message'; +import PageTemplate, { renderToString } from '../../components/PageTemplate'; +import Message from '../../components/Message'; import AlertIcon from 'feather-icons/dist/icons/alert-octagon.svg'; -module.exports = '' + ReactDOMServer.renderToString( +export default renderToString(