mirror of
https://github.com/sergeyyarkov/devthread.ru.git
synced 2026-10-11 10:19:13 +03:00
renred upd
This commit is contained in:
parent
bd45a806f9
commit
d89f17cd83
@ -1,18 +1,13 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Link } from 'gatsby'
|
import { Link } from 'gatsby'
|
||||||
import slugify from '../../../helpers/slugify'
|
|
||||||
import useCategoriesQuery from '../../../hooks/useCategoriesQuery'
|
|
||||||
|
|
||||||
const Categories = () => {
|
const Categories = ({ children }) => {
|
||||||
const { edges } = useCategoriesQuery()
|
|
||||||
return (
|
return (
|
||||||
<div className="articles-categories">
|
<div className="articles-categories">
|
||||||
<div className="tag-item">
|
<div className="tag-item">
|
||||||
<Link to='/articles'>Все</Link>
|
<Link to='/articles'>Все</Link>
|
||||||
</div>
|
</div>
|
||||||
{edges.map(({ node }, i) => <div key={i} className="tag-item">
|
{children}
|
||||||
<Link to={`/category/${slugify(node.frontmatter.title)}`}>{node.frontmatter.title}</Link>
|
|
||||||
</div>)}
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
16
src/components/Articles/Categories/CategoryItem.js
Normal file
16
src/components/Articles/Categories/CategoryItem.js
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { useLocation } from '@reach/router'
|
||||||
|
import { Link } from 'gatsby'
|
||||||
|
import slugify from '../../../helpers/slugify'
|
||||||
|
|
||||||
|
const CategoryItem = ({ title }) => {
|
||||||
|
const { pathname } = useLocation()
|
||||||
|
return (
|
||||||
|
<div className={pathname === `/category/${slugify(title)}` ? 'tag-item active' : 'tag-item'}>
|
||||||
|
<Link to={`/category/${slugify(title)}`}>{title}</Link>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default CategoryItem
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ const Offers = () => {
|
|||||||
<p>
|
<p>
|
||||||
В нашем канале telegram вы не пропустите новые статьи, присоединяйтесь к другим разработчикам
|
В нашем канале telegram вы не пропустите новые статьи, присоединяйтесь к другим разработчикам
|
||||||
</p>
|
</p>
|
||||||
<a href="/" target="_blank" className="btn-primary">Подписаться</a>
|
<a href="https://t.me/devthread" rel='noreferrer' target="_blank" className="btn-primary">Подписаться</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -14,7 +14,7 @@ const useCategoriesQuery = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
`)
|
`)
|
||||||
return { edges }
|
return { categories: edges }
|
||||||
}
|
}
|
||||||
|
|
||||||
export default useCategoriesQuery
|
export default useCategoriesQuery
|
||||||
@ -1,14 +1,17 @@
|
|||||||
import React from "react"
|
import React from "react"
|
||||||
import { graphql } from 'gatsby'
|
import { graphql } from 'gatsby'
|
||||||
|
import useCategoriesQuery from '../hooks/useCategoriesQuery'
|
||||||
import SEO from '../components/SEO/SEO'
|
import SEO from '../components/SEO/SEO'
|
||||||
import Layout from '../components/Layout/Layout'
|
import Layout from '../components/Layout/Layout'
|
||||||
import Articles from '../components/Articles/Articles'
|
import Articles from '../components/Articles/Articles'
|
||||||
import Categories from '../components/Articles/Categories/Categories'
|
import Categories from '../components/Articles/Categories/Categories'
|
||||||
|
import CategoryItem from '../components/Articles/Categories/CategoryItem'
|
||||||
import Search from '../components/Articles/Search/Search'
|
import Search from '../components/Articles/Search/Search'
|
||||||
import Offers from '../components/Offers/Offers'
|
import Offers from '../components/Offers/Offers'
|
||||||
import Newsletter from '../components/Newsletter/Newsletter'
|
import Newsletter from '../components/Newsletter/Newsletter'
|
||||||
|
|
||||||
const ArticlesPage = ({ data: { allMarkdownRemark: edges } }) => {
|
const ArticlesPage = ({ data: { allMarkdownRemark: edges } }) => {
|
||||||
|
const { categories } = useCategoriesQuery()
|
||||||
return (
|
return (
|
||||||
<Layout>
|
<Layout>
|
||||||
<SEO title='Статьи' />
|
<SEO title='Статьи' />
|
||||||
@ -20,7 +23,9 @@ const ArticlesPage = ({ data: { allMarkdownRemark: edges } }) => {
|
|||||||
<div className="articles-heading">
|
<div className="articles-heading">
|
||||||
<h1>Статьи</h1>
|
<h1>Статьи</h1>
|
||||||
</div>
|
</div>
|
||||||
<Categories />
|
<Categories>
|
||||||
|
{categories.map(({ node }, i) => <CategoryItem key={i} title={node.frontmatter.title} />)}
|
||||||
|
</Categories>
|
||||||
<Search articlesLength={edges.edges.length} />
|
<Search articlesLength={edges.edges.length} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -39,6 +39,10 @@
|
|||||||
color: #3972f4;
|
color: #3972f4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
&.active a {
|
||||||
|
background: #d8e3fd;
|
||||||
|
color: #3972f4;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.inner {
|
.inner {
|
||||||
@ -114,6 +118,10 @@
|
|||||||
color: #99c9f7;
|
color: #99c9f7;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
&.active a {
|
||||||
|
color: #5183F5;
|
||||||
|
background: #111;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
& .inner {
|
& .inner {
|
||||||
border-bottom: 1px solid rgba(153, 153, 153, 0.2);
|
border-bottom: 1px solid rgba(153, 153, 153, 0.2);
|
||||||
|
|||||||
@ -1,14 +1,17 @@
|
|||||||
import React from "react"
|
import React from "react"
|
||||||
import { graphql } from 'gatsby'
|
import { graphql } from 'gatsby'
|
||||||
|
import useCategoriesQuery from '../hooks/useCategoriesQuery'
|
||||||
import SEO from '../components/SEO/SEO'
|
import SEO from '../components/SEO/SEO'
|
||||||
import Layout from '../components/Layout/Layout'
|
import Layout from '../components/Layout/Layout'
|
||||||
import Articles from '../components/Articles/Articles'
|
import Articles from '../components/Articles/Articles'
|
||||||
import Search from '../components/Articles/Search/Search'
|
import Search from '../components/Articles/Search/Search'
|
||||||
import Categories from '../components/Articles/Categories/Categories'
|
import Categories from '../components/Articles/Categories/Categories'
|
||||||
|
import CategoryItem from '../components/Articles/Categories/CategoryItem'
|
||||||
import Offers from '../components/Offers/Offers'
|
import Offers from '../components/Offers/Offers'
|
||||||
import Newsletter from '../components/Newsletter/Newsletter'
|
import Newsletter from '../components/Newsletter/Newsletter'
|
||||||
|
|
||||||
const CategoryPage = ({ data: { allMarkdownRemark: edges }, pageContext: { title } }) => {
|
const CategoryPage = ({ data: { allMarkdownRemark: edges }, pageContext: { title } }) => {
|
||||||
|
const { categories } = useCategoriesQuery()
|
||||||
return (
|
return (
|
||||||
<Layout>
|
<Layout>
|
||||||
<SEO title={title} />
|
<SEO title={title} />
|
||||||
@ -20,7 +23,9 @@ const CategoryPage = ({ data: { allMarkdownRemark: edges }, pageContext: { title
|
|||||||
<div className="articles-heading">
|
<div className="articles-heading">
|
||||||
<h1>Статьи</h1>
|
<h1>Статьи</h1>
|
||||||
</div>
|
</div>
|
||||||
<Categories />
|
<Categories>
|
||||||
|
{categories.map(({ node }, i) => <CategoryItem key={i} title={node.frontmatter.title} />)}
|
||||||
|
</Categories>
|
||||||
<Search articlesLength={edges.edges.length} />
|
<Search articlesLength={edges.edges.length} />
|
||||||
<div className="articles-info">
|
<div className="articles-info">
|
||||||
<p>Показано {edges.edges.length} из категории "{title}"</p>
|
<p>Показано {edges.edges.length} из категории "{title}"</p>
|
||||||
|
|||||||
@ -1,14 +1,17 @@
|
|||||||
import React from "react"
|
import React from "react"
|
||||||
import { graphql } from 'gatsby'
|
import { graphql } from 'gatsby'
|
||||||
|
import useCategoriesQuery from '../hooks/useCategoriesQuery'
|
||||||
import SEO from '../components/SEO/SEO'
|
import SEO from '../components/SEO/SEO'
|
||||||
import Layout from '../components/Layout/Layout'
|
import Layout from '../components/Layout/Layout'
|
||||||
import Articles from '../components/Articles/Articles'
|
import Articles from '../components/Articles/Articles'
|
||||||
import Search from '../components/Articles/Search/Search'
|
import Search from '../components/Articles/Search/Search'
|
||||||
import Categories from '../components/Articles/Categories/Categories'
|
import Categories from '../components/Articles/Categories/Categories'
|
||||||
|
import CategoryItem from '../components/Articles/Categories/CategoryItem'
|
||||||
import Offers from '../components/Offers/Offers'
|
import Offers from '../components/Offers/Offers'
|
||||||
import Newsletter from '../components/Newsletter/Newsletter'
|
import Newsletter from '../components/Newsletter/Newsletter'
|
||||||
|
|
||||||
const TagPage = ({ data: { allMarkdownRemark: edges }, pageContext: { title } }) => {
|
const TagPage = ({ data: { allMarkdownRemark: edges }, pageContext: { title } }) => {
|
||||||
|
const { categories } = useCategoriesQuery()
|
||||||
return (
|
return (
|
||||||
<Layout>
|
<Layout>
|
||||||
<SEO title={title} />
|
<SEO title={title} />
|
||||||
@ -20,7 +23,9 @@ const TagPage = ({ data: { allMarkdownRemark: edges }, pageContext: { title } })
|
|||||||
<div className="articles-heading">
|
<div className="articles-heading">
|
||||||
<h1>Статьи</h1>
|
<h1>Статьи</h1>
|
||||||
</div>
|
</div>
|
||||||
<Categories />
|
<Categories>
|
||||||
|
{categories.map(({ node }, i) => <CategoryItem key={i} title={node.frontmatter.title} />)}
|
||||||
|
</Categories>
|
||||||
<Search articlesLength={edges.edges.length} />
|
<Search articlesLength={edges.edges.length} />
|
||||||
<div className="articles-info">
|
<div className="articles-info">
|
||||||
<p>Показано {edges.edges.length} по тегу "{title}"</p>
|
<p>Показано {edges.edges.length} по тегу "{title}"</p>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user