mirror of
https://github.com/sergeyyarkov/devthread.ru.git
synced 2026-10-11 10:19:13 +03:00
load more in sitemetadata
This commit is contained in:
parent
0af865962d
commit
069195d150
@ -29,6 +29,12 @@ module.exports = {
|
|||||||
telegram: 'https://t.me/devthread',
|
telegram: 'https://t.me/devthread',
|
||||||
twitter: 'https://twitter.com/devthread',
|
twitter: 'https://twitter.com/devthread',
|
||||||
yadzen: 'https://zen.yandex.ru/'
|
yadzen: 'https://zen.yandex.ru/'
|
||||||
|
},
|
||||||
|
options: {
|
||||||
|
articles: {
|
||||||
|
onPage: 6,
|
||||||
|
onLoadMore: 2
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
|
|||||||
@ -1,9 +1,11 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
|
import useSiteMetadataQuery from '../../hooks/useSiteMetadataQuery'
|
||||||
import ArticleCard from './ArticleCard/ArticleCard'
|
import ArticleCard from './ArticleCard/ArticleCard'
|
||||||
import Newsletter from '../Newsletter/Newsletter'
|
import Newsletter from '../Newsletter/Newsletter'
|
||||||
|
|
||||||
const Articles = ({ data: { edges }, limit = 6, setLimit = () => null }) => {
|
const Articles = ({ data: { edges }, limit = 6, setLimit = () => null }) => {
|
||||||
|
const { siteMetadata: { options: { articles: { onLoadMore } } } } = useSiteMetadataQuery()
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="articles">
|
<div className="articles">
|
||||||
@ -21,7 +23,7 @@ const Articles = ({ data: { edges }, limit = 6, setLimit = () => null }) => {
|
|||||||
<div className="articles-loadMore">
|
<div className="articles-loadMore">
|
||||||
{edges.length === limit || edges.length <= limit
|
{edges.length === limit || edges.length <= limit
|
||||||
? null
|
? null
|
||||||
: <button className='btn-loadMore' onClick={() => setLimit(limit + 2)}>Загрузить еще <span role='img' aria-label='load more'>👇</span></button>
|
: <button className='btn-loadMore' onClick={() => setLimit(limit + onLoadMore)}>Загрузить еще <span role='img' aria-label='load more'>👇</span></button>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -21,6 +21,12 @@ const useSiteMetadata = () => {
|
|||||||
twitter
|
twitter
|
||||||
yadzen
|
yadzen
|
||||||
}
|
}
|
||||||
|
options {
|
||||||
|
articles {
|
||||||
|
onPage
|
||||||
|
onLoadMore
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import { graphql } from 'gatsby'
|
|||||||
import { useLocation } from '@reach/router'
|
import { useLocation } from '@reach/router'
|
||||||
import * as queryString from 'query-string'
|
import * as queryString from 'query-string'
|
||||||
import useCategoriesQuery from '../hooks/useCategoriesQuery'
|
import useCategoriesQuery from '../hooks/useCategoriesQuery'
|
||||||
|
import useSiteMetadataQuery from '../hooks/useSiteMetadataQuery'
|
||||||
|
|
||||||
import SEO from '../components/SEO/SEO'
|
import SEO from '../components/SEO/SEO'
|
||||||
import Layout from '../components/Layout/Layout'
|
import Layout from '../components/Layout/Layout'
|
||||||
@ -18,9 +19,10 @@ import SearchIcon from '../images/search-icon.svg'
|
|||||||
|
|
||||||
const ArticlesPage = ({ data: { allMarkdownRemark: edges }, }) => {
|
const ArticlesPage = ({ data: { allMarkdownRemark: edges }, }) => {
|
||||||
const { categories } = useCategoriesQuery()
|
const { categories } = useCategoriesQuery()
|
||||||
|
const { siteMetadata: { options: { articles: { onPage } } } } = useSiteMetadataQuery()
|
||||||
const { search } = useLocation()
|
const { search } = useLocation()
|
||||||
|
|
||||||
let [limit, setLimit] = React.useState(6)
|
let [limit, setLimit] = React.useState(onPage)
|
||||||
const [filtredArticles, setFiltredArticles] = React.useState([])
|
const [filtredArticles, setFiltredArticles] = React.useState([])
|
||||||
const [query, setQuery] = React.useState(queryString.parse(search).search || '')
|
const [query, setQuery] = React.useState(queryString.parse(search).search || '')
|
||||||
|
|
||||||
|
|||||||
@ -13,9 +13,9 @@ import Offers from '../components/Offers/Offers'
|
|||||||
|
|
||||||
const CategoryPage = ({ data: { allMarkdownRemark: edges }, pageContext: { title } }) => {
|
const CategoryPage = ({ data: { allMarkdownRemark: edges }, pageContext: { title } }) => {
|
||||||
const { categories } = useCategoriesQuery()
|
const { categories } = useCategoriesQuery()
|
||||||
const { siteMetadata: { siteUrl } } = useSiteMetadataQuery()
|
const { siteMetadata: { siteUrl, options: { articles: { onPage } } } } = useSiteMetadataQuery()
|
||||||
|
|
||||||
let [limit, setLimit] = React.useState(6)
|
let [limit, setLimit] = React.useState(onPage)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Layout>
|
<Layout>
|
||||||
|
|||||||
@ -13,9 +13,9 @@ import Offers from '../components/Offers/Offers'
|
|||||||
|
|
||||||
const TagPage = ({ data: { allMarkdownRemark: edges }, pageContext: { title } }) => {
|
const TagPage = ({ data: { allMarkdownRemark: edges }, pageContext: { title } }) => {
|
||||||
const { categories } = useCategoriesQuery()
|
const { categories } = useCategoriesQuery()
|
||||||
const { siteMetadata: { siteUrl } } = useSiteMetadataQuery()
|
const { siteMetadata: { siteUrl, options: { articles: { onPage } } } } = useSiteMetadataQuery()
|
||||||
|
|
||||||
let [limit, setLimit] = React.useState(6)
|
let [limit, setLimit] = React.useState(onPage)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Layout>
|
<Layout>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user