diff --git a/src/components/Offers/Offers.js b/src/components/Offers/Offers.js
index b273d11..ef4b642 100644
--- a/src/components/Offers/Offers.js
+++ b/src/components/Offers/Offers.js
@@ -1,34 +1,23 @@
import React from 'react';
+import usePopularArticlesQuery from '../../hooks/usePopularArticlesQuery'
import useTagsQuery from '../../hooks/useTagsQuery'
import './Offers.scss'
+import Popular from './Popular/Popular'
+import PopularItem from './Popular/PopularItem'
import Tags from './Tags/Tags'
import TagItem from './Tags/TagItem'
-import PopularIcon from '../../images/popular-icon.svg'
-import ViewsIcon from '../../images/views-icon.svg'
import BooksIcon from '../../images/books-icon.svg'
const Offers = () => {
+ const { articles } = usePopularArticlesQuery()
const { tags } = useTagsQuery()
return (
-
-
-
- {[1,2,3,4,5].map(e =>
)}
-
-
+
+ {articles.map(({ node }, i) => )}
+
{tags.map(({ node }, i) => )}
diff --git a/src/components/Offers/Offers.scss b/src/components/Offers/Offers.scss
index 1d03a9b..0800562 100644
--- a/src/components/Offers/Offers.scss
+++ b/src/components/Offers/Offers.scss
@@ -17,7 +17,6 @@
margin-bottom: 15px;
}
& .offers-popular {
- min-height: 400px;
&__content {
& .article-item {
margin-bottom: 10px;
@@ -50,7 +49,6 @@
}
}
& .offers-books {
- min-height: 330px;
&__content {
& .book-item {
margin-bottom: 10px;
diff --git a/src/components/Offers/Popular/Popular.js b/src/components/Offers/Popular/Popular.js
new file mode 100644
index 0000000..c0af8e1
--- /dev/null
+++ b/src/components/Offers/Popular/Popular.js
@@ -0,0 +1,18 @@
+import React from 'react';
+
+import PopularIcon from '../../../images/popular-icon.svg'
+
+const Popular = ({ children }) => {
+ return (
+
+ )
+}
+
+export default Popular
\ No newline at end of file
diff --git a/src/components/Offers/Popular/PopularItem.js b/src/components/Offers/Popular/PopularItem.js
new file mode 100644
index 0000000..60db7cb
--- /dev/null
+++ b/src/components/Offers/Popular/PopularItem.js
@@ -0,0 +1,20 @@
+import React from 'react';
+import { Link } from 'gatsby'
+
+import ViewsIcon from '../../../images/views-icon.svg'
+
+const PopularItem = ({ slug, title }) => {
+ return (
+
+
+ {title}
+
+
+
+ 4252
+
+
+ )
+}
+
+export default PopularItem
\ No newline at end of file
diff --git a/src/hooks/usePopularArticlesQuery.js b/src/hooks/usePopularArticlesQuery.js
new file mode 100644
index 0000000..e05618f
--- /dev/null
+++ b/src/hooks/usePopularArticlesQuery.js
@@ -0,0 +1,21 @@
+import { useStaticQuery, graphql } from 'gatsby'
+
+const usePopularArticlesQuery = () => {
+ const { allMarkdownRemark: { edges } } = useStaticQuery(graphql`
+ {
+ allMarkdownRemark(filter: {frontmatter: {templateKey: {eq: "article"}, popular: {eq: true}}}, sort: {fields: frontmatter___date, order: DESC}, limit: 5) {
+ edges {
+ node {
+ frontmatter {
+ slug
+ title
+ }
+ }
+ }
+ }
+ }
+ `)
+ return { articles: edges }
+}
+
+export default usePopularArticlesQuery
\ No newline at end of file
diff --git a/static/admin/config.yml b/static/admin/config.yml
index 1a8c562..b833722 100644
--- a/static/admin/config.yml
+++ b/static/admin/config.yml
@@ -14,6 +14,7 @@ collections:
- {label: "Slug", name: "slug", widget: "string"}
- {label: "Время чтения", name: "time", widget: "string"}
- {label: "Заголовок", name: "title", widget: "string"}
+ - {label: "Популярная статья", name: "popular", widget: "boolean", default: false}
- {label: "Обложка", name: "image", widget: "image"}
- {label: "Категория", name: "category", widget: "relation", collection: "categories", valueField: "title", searchFields: ["title"]}
- {label: "Дата публикации", name: "date", widget: "datetime"}