diff --git a/gatsby-config.js b/gatsby-config.js index 378c3b8..acf7eee 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -1,6 +1,6 @@ module.exports = { siteMetadata: { - url: 'https://alxshelepenok.github.com/gatsby-starter-lumen', + url: 'https://lumen.netlify.com/', title: 'Blog by John Doe', subtitle: 'Pellentesque odio nisi, euismod in, pharetra a, ultricies in, diam. Sed arcu.', copyright: '© All rights reserved.', @@ -61,8 +61,7 @@ module.exports = { url: site.siteMetadata.url + edge.node.fields.slug, guid: site.siteMetadata.url + edge.node.fields.slug, custom_elements: [{ 'content:encoded': edge.node.html }] - }) - ) + })) ), query: ` { @@ -101,15 +100,12 @@ module.exports = { { resolve: 'gatsby-remark-images', options: { - maxWidth: 960, - linkImagesToOriginal: false + maxWidth: 960 } }, { resolve: 'gatsby-remark-responsive-iframe', - options: { - wrapperStyle: 'margin-bottom: 1.0725rem' - } + options: { wrapperStyle: 'margin-bottom: 1.0725rem' } }, 'gatsby-remark-prismjs', 'gatsby-remark-copy-linked-files', @@ -121,9 +117,7 @@ module.exports = { 'gatsby-plugin-sharp', { resolve: 'gatsby-plugin-google-analytics', - options: { - trackingId: '' - } + options: { trackingId: '' } }, { resolve: 'gatsby-plugin-sitemap', diff --git a/gatsby-node.js b/gatsby-node.js index cb5c1a9..baf5b41 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -9,13 +9,12 @@ exports.createPages = ({ graphql, boundActionCreators }) => { const { createPage } = boundActionCreators; return new Promise((resolve, reject) => { - const postTemplate = path.resolve('./src/templates/post-template.js'); - const pageTemplate = path.resolve('./src/templates/page-template.js'); - const tagTemplate = path.resolve('./src/templates/tag-template.js'); - const categoryTemplate = path.resolve('./src/templates/category-template.js'); + const postTemplate = path.resolve('./src/templates/post-template.jsx'); + const pageTemplate = path.resolve('./src/templates/page-template.jsx'); + const tagTemplate = path.resolve('./src/templates/tag-template.jsx'); + const categoryTemplate = path.resolve('./src/templates/category-template.jsx'); - graphql( - ` + graphql(` { allMarkdownRemark( limit: 1000, @@ -35,8 +34,7 @@ exports.createPages = ({ graphql, boundActionCreators }) => { } } } - ` - ).then((result) => { + `).then((result) => { if (result.errors) { console.log(result.errors); reject(result.errors); @@ -47,17 +45,13 @@ exports.createPages = ({ graphql, boundActionCreators }) => { createPage({ path: edge.node.fields.slug, component: slash(pageTemplate), - context: { - slug: edge.node.fields.slug - } + context: { slug: edge.node.fields.slug } }); } else if (_.get(edge, 'node.frontmatter.layout') === 'post') { createPage({ path: edge.node.fields.slug, component: slash(postTemplate), - context: { - slug: edge.node.fields.slug - } + context: { slug: edge.node.fields.slug } }); let tags = []; @@ -71,9 +65,7 @@ exports.createPages = ({ graphql, boundActionCreators }) => { createPage({ path: tagPath, component: tagTemplate, - context: { - tag - } + context: { tag } }); }); @@ -88,9 +80,7 @@ exports.createPages = ({ graphql, boundActionCreators }) => { createPage({ path: categoryPath, component: categoryTemplate, - context: { - category - } + context: { category } }); }); } @@ -124,9 +114,7 @@ exports.onCreateNode = ({ node, boundActionCreators, getNode }) => { }); if (node.frontmatter.tags) { - const tagSlugs = node.frontmatter.tags.map( - tag => `/tags/${_.kebabCase(tag)}/` - ); + const tagSlugs = node.frontmatter.tags.map(tag => `/tags/${_.kebabCase(tag)}/`); createNodeField({ node, name: 'tagSlugs', value: tagSlugs }); } diff --git a/src/components/CategoryTemplateDetails/index.jsx b/src/components/CategoryTemplateDetails/index.jsx index 8fc7d98..47b4f1e 100644 --- a/src/components/CategoryTemplateDetails/index.jsx +++ b/src/components/CategoryTemplateDetails/index.jsx @@ -1,16 +1,13 @@ import React from 'react'; -import PropTypes from 'prop-types'; import Post from '../Post'; class CategoryTemplateDetails extends React.Component { render() { const items = []; - const category = this.props.pathContext.category; + const { category } = this.props.pathContext; const posts = this.props.data.allMarkdownRemark.edges; posts.forEach((post) => { - items.push( - - ); + items.push(); }); return ( @@ -30,15 +27,4 @@ class CategoryTemplateDetails extends React.Component { } } -CategoryTemplateDetails.propTypes = { - data: PropTypes.shape({ - allMarkdownRemark: PropTypes.shape({ - edges: PropTypes.array.isRequired - }) - }), - pathContext: PropTypes.shape({ - category: PropTypes.string.isRequired - }) -}; - export default CategoryTemplateDetails; diff --git a/src/components/Disqus/Disqus.jsx b/src/components/Disqus/Disqus.jsx index 632cc8d..6a8b2d7 100644 --- a/src/components/Disqus/Disqus.jsx +++ b/src/components/Disqus/Disqus.jsx @@ -1,14 +1,11 @@ import React, { Component } from 'react'; -import PropTypes from 'prop-types'; import ReactDisqusComments from 'react-disqus-comments'; import config from '../../../gatsby-config'; class Disqus extends Component { constructor(props) { super(props); - this.state = { - toasts: [] - }; + this.state = { toasts: [] }; this.notifyAboutComment = this.notifyAboutComment.bind(this); this.onSnackbarDismiss = this.onSnackbarDismiss.bind(this); } @@ -42,8 +39,4 @@ class Disqus extends Component { } } -Disqus.propTypes = { - postNode: PropTypes.object.isRequired -}; - export default Disqus; diff --git a/src/components/Links/index.jsx b/src/components/Links/index.jsx index 027cbd7..dabef0b 100644 --- a/src/components/Links/index.jsx +++ b/src/components/Links/index.jsx @@ -1,5 +1,4 @@ import React from 'react'; -import PropTypes from 'prop-types'; import './style.scss'; import '../../assets/fonts/fontello-771c82e0/css/fontello.css'; @@ -19,17 +18,17 @@ class Links extends React.Component {
  • - +
  • - +
  • - +
  • @@ -58,8 +57,4 @@ class Links extends React.Component { } } -Links.propTypes = { - data: PropTypes.object.isRequired -}; - export default Links; diff --git a/src/components/Menu/index.jsx b/src/components/Menu/index.jsx index b2c4821..0b981e6 100644 --- a/src/components/Menu/index.jsx +++ b/src/components/Menu/index.jsx @@ -1,5 +1,4 @@ import React from 'react'; -import PropTypes from 'prop-types'; import Link from 'gatsby-link'; import './style.scss'; @@ -9,17 +8,18 @@ class Menu extends React.Component { const menuBlock = (
      - {menu.map(item => + {menu.map(item => (
    • {item.label}
    • - )} + ))}
    ); @@ -31,8 +31,4 @@ class Menu extends React.Component { } } -Menu.propTypes = { - data: PropTypes.array.isRequired -}; - export default Menu; diff --git a/src/components/PageTemplateDetails/index.jsx b/src/components/PageTemplateDetails/index.jsx index 0462720..8560ba7 100644 --- a/src/components/PageTemplateDetails/index.jsx +++ b/src/components/PageTemplateDetails/index.jsx @@ -1,5 +1,4 @@ import React from 'react'; -import PropTypes from 'prop-types'; import Sidebar from '../Sidebar'; import './style.scss'; @@ -23,10 +22,4 @@ class PageTemplateDetails extends React.Component { } } -PageTemplateDetails.propTypes = { - data: PropTypes.shape({ - markdownRemark: PropTypes.object.isRequired - }) -}; - export default PageTemplateDetails; diff --git a/src/components/Post/index.jsx b/src/components/Post/index.jsx index 38ba166..ca301bb 100644 --- a/src/components/Post/index.jsx +++ b/src/components/Post/index.jsx @@ -1,46 +1,34 @@ import React from 'react'; -import PropTypes from 'prop-types'; import Link from 'gatsby-link'; import moment from 'moment'; import './style.scss'; class Post extends React.Component { render() { - const data = this.props.data; - const post = { - title: data.node.frontmatter.title, - slug: data.node.fields.slug, - description: data.node.frontmatter.description, - date: data.node.frontmatter.date, - category: data.node.frontmatter.category, - categorySlug: data.node.fields.categorySlug - }; + const { title, date, category, description } = this.props.data.node.frontmatter; + const { slug, categorySlug } = this.props.data.node.fields; return (
    -

    - {post.title} + {title}

    -

    {post.description}

    - Read +

    {description}

    + Read
    ); } } -Post.propTypes = { - data: PropTypes.object.isRequired -}; - export default Post; diff --git a/src/components/PostTemplateDetails/index.jsx b/src/components/PostTemplateDetails/index.jsx index 3b23674..283738c 100644 --- a/src/components/PostTemplateDetails/index.jsx +++ b/src/components/PostTemplateDetails/index.jsx @@ -1,5 +1,4 @@ import React from 'react'; -import PropTypes from 'prop-types'; import Link from 'gatsby-link'; import moment from 'moment'; import Disqus from '../Disqus/Disqus'; @@ -20,13 +19,13 @@ class PostTemplateDetails extends React.Component { const tagsBlock = (
      - {tags && tags.map((tag, i) => + {tags && tags.map((tag, i) => (
    • {post.frontmatter.tags[i]}
    • - )} + ))}
    ); @@ -65,16 +64,4 @@ class PostTemplateDetails extends React.Component { } } -PostTemplateDetails.propTypes = { - data: PropTypes.shape({ - site: PropTypes.shape({ - siteMetadata: PropTypes.shape({ - subtitle: PropTypes.string.isRequired, - author: PropTypes.object.isRequired - }) - }), - markdownRemark: PropTypes.object.isRequired - }) -}; - export default PostTemplateDetails; diff --git a/src/components/Sidebar/index.jsx b/src/components/Sidebar/index.jsx index d1fbe14..7bc54f0 100644 --- a/src/components/Sidebar/index.jsx +++ b/src/components/Sidebar/index.jsx @@ -1,5 +1,4 @@ import React from 'react'; -import PropTypes from 'prop-types'; import get from 'lodash/get'; import Link from 'gatsby-link'; import Menu from '../Menu'; @@ -13,14 +12,15 @@ class Sidebar extends React.Component { const { author, subtitle, copyright, menu } = this.props.data.site.siteMetadata; const isHomePage = get(location, 'pathname', '/') === '/'; - /* eslint-disable jsx-a11y/img-redundant-alt*/ + /* eslint-disable jsx-a11y/img-redundant-alt */ const authorBlock = (
    {author.name} @@ -36,7 +36,7 @@ class Sidebar extends React.Component {

    {subtitle}

    ); - /* eslint-enable jsx-a11y/img-redundant-alt*/ + /* eslint-enable jsx-a11y/img-redundant-alt */ return (
    @@ -57,18 +57,4 @@ class Sidebar extends React.Component { } } -Sidebar.propTypes = { - data: PropTypes.shape({ - site: PropTypes.shape({ - siteMetadata: PropTypes.shape({ - subtitle: PropTypes.string.isRequired, - author: PropTypes.object.isRequired, - copyright: PropTypes.string.isRequired, - menu: PropTypes.array.isRequired - }) - }) - }), - location: PropTypes.object -}; - export default Sidebar; diff --git a/src/components/TagTemplateDetails/index.jsx b/src/components/TagTemplateDetails/index.jsx index ddeaaff..69c9600 100644 --- a/src/components/TagTemplateDetails/index.jsx +++ b/src/components/TagTemplateDetails/index.jsx @@ -1,5 +1,4 @@ import React from 'react'; -import PropTypes from 'prop-types'; import Post from '../Post'; class TagTemplateDetails extends React.Component { @@ -8,9 +7,7 @@ class TagTemplateDetails extends React.Component { const tagTitle = this.props.pathContext.tag; const posts = this.props.data.allMarkdownRemark.edges; posts.forEach((post) => { - items.push( - - ); + items.push(); }); return ( @@ -30,15 +27,4 @@ class TagTemplateDetails extends React.Component { } } -TagTemplateDetails.propTypes = { - data: PropTypes.shape({ - allMarkdownRemark: PropTypes.shape({ - edges: PropTypes.array.isRequired - }) - }), - pathContext: PropTypes.shape({ - tag: PropTypes.string.isRequired - }) -}; - export default TagTemplateDetails; diff --git a/src/html.js b/src/html.js deleted file mode 100644 index a046d05..0000000 --- a/src/html.js +++ /dev/null @@ -1,57 +0,0 @@ -import React from 'react'; -import PropTypes from 'prop-types'; - -class HTML extends React.Component { - render() { - const { postBodyComponents, headComponents, body } = this.props; - let styles; - if (process.env.NODE_ENV === 'production') { - try { - // eslint-disable-next-line import/no-webpack-loader-syntax - styles = require('!raw-loader!../public/styles.css'); - } catch (e) { - console.log(e); - } - } - - let css; - if (process.env.NODE_ENV === 'production') { - css = ( -