mirror of
https://github.com/sergeyyarkov/devthread.ru.git
synced 2026-10-11 10:19:13 +03:00
tag offers
This commit is contained in:
parent
cc664a8a24
commit
2cbff1dfd7
@ -1,9 +1,9 @@
|
||||
import React from 'react';
|
||||
import './Offers.scss'
|
||||
import Tags from './Tags/Tags'
|
||||
|
||||
import PopularIcon from '../../images/popular-icon.svg'
|
||||
import ViewsIcon from '../../images/views-icon.svg'
|
||||
import TagIcon from '../../images/tag-icon.svg'
|
||||
import BooksIcon from '../../images/books-icon.svg'
|
||||
|
||||
const Offers = () => {
|
||||
@ -25,53 +25,7 @@ const Offers = () => {
|
||||
</div>)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="offers-tags offer-box">
|
||||
<div className="offers-tags__heading offer-heading">
|
||||
<TagIcon />
|
||||
Тэги
|
||||
</div>
|
||||
<div className="offers-tags__content">
|
||||
<div className="tag-item">
|
||||
<a href="/">serverless</a>
|
||||
</div>
|
||||
<div className="tag-item">
|
||||
<a href="/">reactjs</a>
|
||||
</div>
|
||||
<div className="tag-item">
|
||||
<a href="/">nodejs</a>
|
||||
</div>
|
||||
<div className="tag-item">
|
||||
<a href="/">graphql</a>
|
||||
</div>
|
||||
<div className="tag-item">
|
||||
<a href="/">seo</a>
|
||||
</div>
|
||||
<div className="tag-item">
|
||||
<a href="/">ооп</a>
|
||||
</div>
|
||||
<div className="tag-item">
|
||||
<a href="/">gatsby</a>
|
||||
</div>
|
||||
<div className="tag-item">
|
||||
<a href="/">nextjs</a>
|
||||
</div>
|
||||
<div className="tag-item">
|
||||
<a href="/">jquery</a>
|
||||
</div>
|
||||
<div className="tag-item">
|
||||
<a href="/">mysql</a>
|
||||
</div>
|
||||
<div className="tag-item">
|
||||
<a href="/">php</a>
|
||||
</div>
|
||||
<div className="tag-item">
|
||||
<a href="/">python</a>
|
||||
</div>
|
||||
<div className="tag-item">
|
||||
<a href="/">jekyll</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<Tags />
|
||||
<div className="offers-books offer-box">
|
||||
<div className="offers-books__heading offer-heading">
|
||||
<BooksIcon />
|
||||
|
||||
@ -44,7 +44,6 @@
|
||||
}
|
||||
}
|
||||
& .offers-tags {
|
||||
min-height: 200px;
|
||||
&__content {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
|
||||
32
src/components/Offers/Tags/Tags.js
Normal file
32
src/components/Offers/Tags/Tags.js
Normal file
@ -0,0 +1,32 @@
|
||||
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'
|
||||
|
||||
const TagItem = ({ title }) => {
|
||||
return (
|
||||
<div className="tag-item">
|
||||
<Link to={`/tag/${sligify(title)}`}>{title}</Link>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const Tags = () => {
|
||||
const { edges } = useTagsQuery()
|
||||
|
||||
return (
|
||||
<div className="offers-tags offer-box">
|
||||
<div className="offers-tags__heading offer-heading">
|
||||
<TagIcon />
|
||||
Тэги
|
||||
</div>
|
||||
<div className="offers-tags__content">
|
||||
{edges.map(({ node }, i) => <TagItem key={i} title={node.frontmatter.title} />)}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default Tags
|
||||
20
src/hooks/useTagsQuery.js
Normal file
20
src/hooks/useTagsQuery.js
Normal file
@ -0,0 +1,20 @@
|
||||
import { useStaticQuery, graphql } from 'gatsby'
|
||||
|
||||
const useTagsQuery = () => {
|
||||
const { allMarkdownRemark: { edges } } = useStaticQuery(graphql`
|
||||
{
|
||||
allMarkdownRemark(filter: {frontmatter: {templateKey: {eq: "tag"}}}) {
|
||||
edges {
|
||||
node {
|
||||
frontmatter {
|
||||
title
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`)
|
||||
return { edges }
|
||||
}
|
||||
|
||||
export default useTagsQuery
|
||||
@ -8,7 +8,7 @@ collections:
|
||||
label: "Article"
|
||||
folder: "content/articles"
|
||||
create: true
|
||||
slug: "{{year}}-{{month}}-{{day}}-{{slug}}"
|
||||
slug: "{{slug}}"
|
||||
fields:
|
||||
- {label: "Template Key", name: "templateKey", wisdget: "hidden", default: "article"}
|
||||
- {label: "Slug", name: "slug", widget: "string"}
|
||||
@ -24,7 +24,7 @@ collections:
|
||||
label: "Category"
|
||||
folder: 'content/categories'
|
||||
create: true
|
||||
slug: "{{year}}-{{month}}-{{day}}-{{slug}}"
|
||||
slug: "{{year}}-{{month}}-{{day}}"
|
||||
fields:
|
||||
- {label: "Template key", name: "templateKey", widget: "hidden", default: "category"}
|
||||
- {label: "Название категории", name: "title", widget: "string"}
|
||||
@ -32,7 +32,7 @@ collections:
|
||||
label: "Tag"
|
||||
folder: 'content/tags'
|
||||
create: true
|
||||
slug: "{{year}}-{{month}}-{{day}}-{{slug}}"
|
||||
slug: "{{year}}-{{month}}-{{day}}"
|
||||
fields:
|
||||
- {label: "Template key", name: "templateKey", widget: "hidden", default: "tag"}
|
||||
- {label: "Название тэга", name: "title", widget: "string"}
|
||||
Loading…
x
Reference in New Issue
Block a user