mirror of
https://github.com/sergeyyarkov/devthread.ru.git
synced 2026-10-11 18:29:10 +03:00
render tag
This commit is contained in:
parent
11d7f91fdc
commit
bd45a806f9
@ -1,12 +1,16 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import useTagsQuery from '../../hooks/useTagsQuery'
|
||||||
import './Offers.scss'
|
import './Offers.scss'
|
||||||
import Tags from './Tags/Tags'
|
import Tags from './Tags/Tags'
|
||||||
|
import TagItem from './Tags/TagItem'
|
||||||
|
|
||||||
import PopularIcon from '../../images/popular-icon.svg'
|
import PopularIcon from '../../images/popular-icon.svg'
|
||||||
import ViewsIcon from '../../images/views-icon.svg'
|
import ViewsIcon from '../../images/views-icon.svg'
|
||||||
import BooksIcon from '../../images/books-icon.svg'
|
import BooksIcon from '../../images/books-icon.svg'
|
||||||
|
|
||||||
const Offers = () => {
|
const Offers = () => {
|
||||||
|
const { tags } = useTagsQuery()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="offers">
|
<div className="offers">
|
||||||
<div className="offers-popular offer-box">
|
<div className="offers-popular offer-box">
|
||||||
@ -25,7 +29,9 @@ const Offers = () => {
|
|||||||
</div>)}
|
</div>)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Tags />
|
<Tags>
|
||||||
|
{tags.map(({ node }, i) => <TagItem key={i} title={node.frontmatter.title} />)}
|
||||||
|
</Tags>
|
||||||
<div className="offers-books offer-box">
|
<div className="offers-books offer-box">
|
||||||
<div className="offers-books__heading offer-heading">
|
<div className="offers-books__heading offer-heading">
|
||||||
<BooksIcon />
|
<BooksIcon />
|
||||||
|
|||||||
13
src/components/Offers/Tags/TagItem.js
Normal file
13
src/components/Offers/Tags/TagItem.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { Link } from 'gatsby'
|
||||||
|
import sligify from '../../../helpers/slugify'
|
||||||
|
|
||||||
|
const TagItem = ({ title }) => {
|
||||||
|
return (
|
||||||
|
<div className="tag-item">
|
||||||
|
<Link to={`/tag/${sligify(title)}`}>{title}</Link>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default TagItem
|
||||||
@ -1,20 +1,8 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { Link } from 'gatsby'
|
|
||||||
import sligify from '../../../helpers/slugify'
|
|
||||||
import useTagsQuery from '../../../hooks/useTagsQuery'
|
|
||||||
|
|
||||||
import TagIcon from '../../../images/tag-icon.svg'
|
import TagIcon from '../../../images/tag-icon.svg'
|
||||||
|
|
||||||
const TagItem = ({ title }) => {
|
const Tags = ({ children }) => {
|
||||||
return (
|
|
||||||
<div className="tag-item">
|
|
||||||
<Link to={`/tag/${sligify(title)}`}>{title}</Link>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
const Tags = () => {
|
|
||||||
const { edges } = useTagsQuery()
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="offers-tags offer-box">
|
<div className="offers-tags offer-box">
|
||||||
@ -23,7 +11,7 @@ const Tags = () => {
|
|||||||
Тэги
|
Тэги
|
||||||
</div>
|
</div>
|
||||||
<div className="offers-tags__content">
|
<div className="offers-tags__content">
|
||||||
{edges.map(({ node }, i) => <TagItem key={i} title={node.frontmatter.title} />)}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@ -14,7 +14,7 @@ const useTagsQuery = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
`)
|
`)
|
||||||
return { edges }
|
return { tags: edges }
|
||||||
}
|
}
|
||||||
|
|
||||||
export default useTagsQuery
|
export default useTagsQuery
|
||||||
Loading…
x
Reference in New Issue
Block a user