mirror of
https://github.com/sergeyyarkov/devthread.ru.git
synced 2026-10-11 02:09:04 +03:00
tag offers
This commit is contained in:
parent
cc664a8a24
commit
2cbff1dfd7
@ -1,9 +1,9 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import './Offers.scss'
|
import './Offers.scss'
|
||||||
|
import Tags from './Tags/Tags'
|
||||||
|
|
||||||
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 TagIcon from '../../images/tag-icon.svg'
|
|
||||||
import BooksIcon from '../../images/books-icon.svg'
|
import BooksIcon from '../../images/books-icon.svg'
|
||||||
|
|
||||||
const Offers = () => {
|
const Offers = () => {
|
||||||
@ -25,53 +25,7 @@ const Offers = () => {
|
|||||||
</div>)}
|
</div>)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="offers-tags offer-box">
|
<Tags />
|
||||||
<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>
|
|
||||||
<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 />
|
||||||
|
|||||||
@ -44,7 +44,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
& .offers-tags {
|
& .offers-tags {
|
||||||
min-height: 200px;
|
|
||||||
&__content {
|
&__content {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
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"
|
label: "Article"
|
||||||
folder: "content/articles"
|
folder: "content/articles"
|
||||||
create: true
|
create: true
|
||||||
slug: "{{year}}-{{month}}-{{day}}-{{slug}}"
|
slug: "{{slug}}"
|
||||||
fields:
|
fields:
|
||||||
- {label: "Template Key", name: "templateKey", wisdget: "hidden", default: "article"}
|
- {label: "Template Key", name: "templateKey", wisdget: "hidden", default: "article"}
|
||||||
- {label: "Slug", name: "slug", widget: "string"}
|
- {label: "Slug", name: "slug", widget: "string"}
|
||||||
@ -24,7 +24,7 @@ collections:
|
|||||||
label: "Category"
|
label: "Category"
|
||||||
folder: 'content/categories'
|
folder: 'content/categories'
|
||||||
create: true
|
create: true
|
||||||
slug: "{{year}}-{{month}}-{{day}}-{{slug}}"
|
slug: "{{year}}-{{month}}-{{day}}"
|
||||||
fields:
|
fields:
|
||||||
- {label: "Template key", name: "templateKey", widget: "hidden", default: "category"}
|
- {label: "Template key", name: "templateKey", widget: "hidden", default: "category"}
|
||||||
- {label: "Название категории", name: "title", widget: "string"}
|
- {label: "Название категории", name: "title", widget: "string"}
|
||||||
@ -32,7 +32,7 @@ collections:
|
|||||||
label: "Tag"
|
label: "Tag"
|
||||||
folder: 'content/tags'
|
folder: 'content/tags'
|
||||||
create: true
|
create: true
|
||||||
slug: "{{year}}-{{month}}-{{day}}-{{slug}}"
|
slug: "{{year}}-{{month}}-{{day}}"
|
||||||
fields:
|
fields:
|
||||||
- {label: "Template key", name: "templateKey", widget: "hidden", default: "tag"}
|
- {label: "Template key", name: "templateKey", widget: "hidden", default: "tag"}
|
||||||
- {label: "Название тэга", name: "title", widget: "string"}
|
- {label: "Название тэга", name: "title", widget: "string"}
|
||||||
Loading…
x
Reference in New Issue
Block a user