diff --git a/gatsby-config.js b/gatsby-config.js
index 36d689c..afa9e31 100644
--- a/gatsby-config.js
+++ b/gatsby-config.js
@@ -23,7 +23,7 @@ module.exports = {
},
{
name: 'Ресурсы',
- link: '/books'
+ link: '/deleted'
}
],
social: {
diff --git a/src/components/Articles/Search/Search.js b/src/components/Articles/Search/Search.js
index 35bd61e..921fc04 100644
--- a/src/components/Articles/Search/Search.js
+++ b/src/components/Articles/Search/Search.js
@@ -2,18 +2,19 @@ import React from 'react'
import { navigate } from 'gatsby'
import PropTypes from 'prop-types'
-const Search = ({ allArticles, filterArticles, articlesLength, resultsLength, query, setQuery, setFiltredArticles, setLimit }) => {
+const Search = ({ allArticles, filterArticles, articlesLength, resultsLength, query, setQuery, setFiltredArticles, setLimit, onPage }) => {
const handleInput = e => {
const query = e.target.value
if (query === '') {
navigate('/articles/')
setQuery('')
+ setLimit(onPage)
return null
}
navigate(`/articles/?search=${query.trim()}`)
setQuery(query)
setFiltredArticles(filterArticles(allArticles))
- setLimit(6)
+ setLimit(onPage)
}
return (
diff --git a/src/components/Offers/Books/BookItem.js b/src/components/Offers/Books/BookItem.js
deleted file mode 100644
index e4621ba..0000000
--- a/src/components/Offers/Books/BookItem.js
+++ /dev/null
@@ -1,18 +0,0 @@
-import React from 'react';
-import PropTypes from 'prop-types'
-import { Link } from 'gatsby'
-import slugify from '../../../helpers/slugify'
-
-const BookItem = ({ title }) => {
- return (
-
- {title}
-
- )
-}
-
-export default BookItem
-
-BookItem.propTypes = {
- title: PropTypes.string
-}
\ No newline at end of file
diff --git a/src/components/Offers/Books/Books.js b/src/components/Offers/Books/Books.js
deleted file mode 100644
index cb29190..0000000
--- a/src/components/Offers/Books/Books.js
+++ /dev/null
@@ -1,19 +0,0 @@
-import React from 'react';
-
-import BooksIcon from '../../../images/books-icon.svg'
-
-const Books = ({ children }) => {
- return (
-
-
-
- Что почитать
-
-
- {children}
-
-
- )
-}
-
-export default Books
\ No newline at end of file
diff --git a/src/components/Offers/Offers.js b/src/components/Offers/Offers.js
index 2f39a5a..38d0bba 100644
--- a/src/components/Offers/Offers.js
+++ b/src/components/Offers/Offers.js
@@ -2,21 +2,17 @@ import React from 'react';
import { useLocation } from '@reach/router'
import usePopularArticlesQuery from '../../hooks/usePopularArticlesQuery'
import useTagsQuery from '../../hooks/useTagsQuery'
-import useBooksQuery from '../../hooks/useBooksQuery'
import Popular from './Popular/Popular'
import Tags from './Tags/Tags'
-import Books from './Books/Books'
import Subscription from './Subscription/Subscription'
import PopularItem from './Popular/PopularItem'
import TagItem from './Tags/TagItem'
-import BookItem from './Books/BookItem'
const Offers = () => {
const { pathname } = useLocation()
const { articles } = usePopularArticlesQuery()
const { tags } = useTagsQuery()
- const { books } = useBooksQuery()
return (
@@ -26,9 +22,6 @@ const Offers = () => {
{tags.map(({ node }, i) => )}
-
- {books.map(({ node }, i) => )}
-
)
diff --git a/src/hooks/useBooksQuery.js b/src/hooks/useBooksQuery.js
deleted file mode 100644
index 919e617..0000000
--- a/src/hooks/useBooksQuery.js
+++ /dev/null
@@ -1,20 +0,0 @@
-import { useStaticQuery, graphql } from 'gatsby'
-
-const useBooksQuery = () => {
- const { allMarkdownRemark: { edges } } = useStaticQuery(graphql`
- {
- allMarkdownRemark(filter: {frontmatter: {templateKey: {eq: "book"}}}) {
- edges {
- node {
- frontmatter {
- title
- }
- }
- }
- }
- }
- `)
- return { books: edges }
-}
-
-export default useBooksQuery
\ No newline at end of file
diff --git a/src/pages/articles.js b/src/pages/articles.js
index 46f53a2..044e9a8 100644
--- a/src/pages/articles.js
+++ b/src/pages/articles.js
@@ -36,10 +36,12 @@ const ArticlesPage = ({ data: { allMarkdownRemark: edges }, }) => {
|| frontmatter.tags.join('').toLowerCase().includes(query.toLowerCase().trim())
)
}, [query])
+
React.useEffect(() => {
+ setLimit(onPage)
if (query !== '') setFiltredArticles(filterArticles(allArticles.edges))
- }, [setFiltredArticles, filterArticles, allArticles.edges, query])
+ }, [setFiltredArticles, filterArticles, allArticles.edges, query, onPage])
return (
@@ -55,7 +57,7 @@ const ArticlesPage = ({ data: { allMarkdownRemark: edges }, }) => {
{categories.map(({ node }, i) => )}
-
+
{query && query !== '' ? filtredArticles.length === 0 ?
Ничего не найдено
: null : null}
diff --git a/src/pages/books.js b/src/pages/books.js
deleted file mode 100644
index 306c639..0000000
--- a/src/pages/books.js
+++ /dev/null
@@ -1,71 +0,0 @@
-import React from "react"
-import { Main } from '../ui/ui'
-import { Grid, Row, Col } from 'react-flexbox-grid'
-import { graphql } from 'gatsby'
-import SEO from '../components/SEO/SEO'
-import Layout from '../components/Layout/Layout'
-import Books from '../components/Books/Books'
-import Offers from '../components/Offers/Offers'
-import Newsletter from '../components/Newsletter/Newsletter'
-
-import BooksIcon from '../images/books-icon__large.svg'
-
-const BooksPage = ({ data: { allMarkdownRemark: edges } }) => {
- return (
-
-
-
-
-
-
-
-
-
-
Что почитать
-
-
-
- Здесь представлен список книг по программированию, которые стоило бы прочитать
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- )
-}
-
-export const query = graphql`
- {
- allMarkdownRemark(filter: {frontmatter: {templateKey: {eq: "book"}}}) {
- edges {
- node {
- frontmatter {
- title
- image {
- childImageSharp {
- fluid(maxWidth: 1400) {
- ...GatsbyImageSharpFluid
- }
- }
- }
- }
- html
- }
- }
- }
- }
-`
-
-export default BooksPage