mirror of
https://github.com/sergeyyarkov/devthread.ru.git
synced 2026-10-11 10:19:13 +03:00
added books
This commit is contained in:
parent
ac4e619480
commit
8345fbeb56
@ -1,28 +1,17 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import slugify from '../../helpers/slugify'
|
||||||
|
import Img from "gatsby-image"
|
||||||
import './Books.scss'
|
import './Books.scss'
|
||||||
|
|
||||||
const Books = () => {
|
const Books = ({ data: { edges } }) => {
|
||||||
return (
|
return (
|
||||||
<div className="books">
|
<div className="books">
|
||||||
<div className="books-inner inner">
|
<div className="books-inner inner">
|
||||||
<h2>Lorem ipsum dolor sit amet, consectetur adipiscing.</h2>
|
{edges.map(({ node }, i) => <div key={i}>
|
||||||
<p>
|
<h2>{node.frontmatter.title} <a id={slugify(node.frontmatter.title)} href={`/books#${slugify(node.frontmatter.title)}`} className='anchor'>{node.frontmatter.title}</a></h2>
|
||||||
<img src="https://i.imgur.com/2OMOIej.jpg" alt="book" />
|
<Img loading="eager" fadeIn={false} fluid={node.frontmatter.image.childImageSharp.fluid} alt={node.frontmatter.title} />
|
||||||
</p>
|
<div className='md' dangerouslySetInnerHTML={{__html: node.html}}></div>
|
||||||
<p>
|
</div>)}
|
||||||
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit.
|
|
||||||
</p>
|
|
||||||
<p>Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur?</p>
|
|
||||||
<a href="/" target="_blank">купить на litres.ru</a>
|
|
||||||
<h2>Lorem ipsum dolor sit amet, consectetur adipiscing.</h2>
|
|
||||||
<p>
|
|
||||||
<img src="https://i.imgur.com/2OMOIej.jpg" alt="book" />
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit.
|
|
||||||
</p>
|
|
||||||
<p>Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur?</p>
|
|
||||||
<a href="/" target="_blank">купить на litres.ru</a>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@ -14,6 +14,9 @@
|
|||||||
}
|
}
|
||||||
& .books-inner {
|
& .books-inner {
|
||||||
margin-bottom: 35px;
|
margin-bottom: 35px;
|
||||||
|
& .md {
|
||||||
|
margin-top: 15px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
13
src/components/Offers/Books/BookItem.js
Normal file
13
src/components/Offers/Books/BookItem.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { Link } from 'gatsby'
|
||||||
|
import slugify from '../../../helpers/slugify'
|
||||||
|
|
||||||
|
const BookItem = ({ title }) => {
|
||||||
|
return (
|
||||||
|
<div className="book-item">
|
||||||
|
<Link to={`/books#${slugify(title)}`}>{title}</Link>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default BookItem
|
||||||
19
src/components/Offers/Books/Books.js
Normal file
19
src/components/Offers/Books/Books.js
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
import BooksIcon from '../../../images/books-icon.svg'
|
||||||
|
|
||||||
|
const Books = ({ children }) => {
|
||||||
|
return (
|
||||||
|
<div className="offers-books offer-box">
|
||||||
|
<div className="offers-books__heading offer-heading">
|
||||||
|
<BooksIcon />
|
||||||
|
Что почитать
|
||||||
|
</div>
|
||||||
|
<div className="offers-books__content">
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Books
|
||||||
@ -1,19 +1,21 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import usePopularArticlesQuery from '../../hooks/usePopularArticlesQuery'
|
import usePopularArticlesQuery from '../../hooks/usePopularArticlesQuery'
|
||||||
import useTagsQuery from '../../hooks/useTagsQuery'
|
import useTagsQuery from '../../hooks/useTagsQuery'
|
||||||
|
import useBooksQuery from '../../hooks/useBooksQuery'
|
||||||
import './Offers.scss'
|
import './Offers.scss'
|
||||||
import Popular from './Popular/Popular'
|
import Popular from './Popular/Popular'
|
||||||
import Tags from './Tags/Tags'
|
import Tags from './Tags/Tags'
|
||||||
|
import Books from './Books/Books'
|
||||||
import Subscription from './Subscription/Subscription'
|
import Subscription from './Subscription/Subscription'
|
||||||
|
|
||||||
import PopularItem from './Popular/PopularItem'
|
import PopularItem from './Popular/PopularItem'
|
||||||
import TagItem from './Tags/TagItem'
|
import TagItem from './Tags/TagItem'
|
||||||
|
import BookItem from './Books/BookItem'
|
||||||
import BooksIcon from '../../images/books-icon.svg'
|
|
||||||
|
|
||||||
const Offers = () => {
|
const Offers = () => {
|
||||||
const { articles } = usePopularArticlesQuery()
|
const { articles } = usePopularArticlesQuery()
|
||||||
const { tags } = useTagsQuery()
|
const { tags } = useTagsQuery()
|
||||||
|
const { books } = useBooksQuery()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="offers">
|
<div className="offers">
|
||||||
@ -23,17 +25,9 @@ const Offers = () => {
|
|||||||
<Tags>
|
<Tags>
|
||||||
{tags.map(({ node }, i) => <TagItem key={i} title={node.frontmatter.title} />)}
|
{tags.map(({ node }, i) => <TagItem key={i} title={node.frontmatter.title} />)}
|
||||||
</Tags>
|
</Tags>
|
||||||
<div className="offers-books offer-box">
|
<Books>
|
||||||
<div className="offers-books__heading offer-heading">
|
{books.map(({ node }, i) => <BookItem key={i} title={node.frontmatter.title} />)}
|
||||||
<BooksIcon />
|
</Books>
|
||||||
Что почитать
|
|
||||||
</div>
|
|
||||||
<div className="offers-books__content">
|
|
||||||
{[1,2,3,4,5].map(e => <div key={e} className="book-item">
|
|
||||||
<a href="/">Lorem ipsum dolor sit amet, consectetur.</a>
|
|
||||||
</div>)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<Subscription />
|
<Subscription />
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
20
src/hooks/useBooksQuery.js
Normal file
20
src/hooks/useBooksQuery.js
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import { useStaticQuery, graphql } from 'gatsby'
|
||||||
|
|
||||||
|
const useBooksQuery = () => {
|
||||||
|
const { allMarkdownRemark: { edges } } = useStaticQuery(graphql`
|
||||||
|
{
|
||||||
|
allMarkdownRemark(filter: {frontmatter: {templateKey: {eq: "book"}}}) {
|
||||||
|
edges {
|
||||||
|
node {
|
||||||
|
frontmatter {
|
||||||
|
title
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`)
|
||||||
|
return { books: edges }
|
||||||
|
}
|
||||||
|
|
||||||
|
export default useBooksQuery
|
||||||
@ -1,4 +1,5 @@
|
|||||||
import React from "react"
|
import React from "react"
|
||||||
|
import { graphql } from 'gatsby'
|
||||||
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 Books from '../components/Books/Books'
|
import Books from '../components/Books/Books'
|
||||||
@ -7,7 +8,7 @@ import Newsletter from '../components/Newsletter/Newsletter'
|
|||||||
|
|
||||||
import BooksIcon from '../images/books-icon__large.svg'
|
import BooksIcon from '../images/books-icon__large.svg'
|
||||||
|
|
||||||
const BooksPage = () => {
|
const BooksPage = ({ data: { allMarkdownRemark: edges } }) => {
|
||||||
return (
|
return (
|
||||||
<Layout>
|
<Layout>
|
||||||
<SEO title='Ресурсы' />
|
<SEO title='Ресурсы' />
|
||||||
@ -30,7 +31,7 @@ const BooksPage = () => {
|
|||||||
</div>
|
</div>
|
||||||
<div className="row">
|
<div className="row">
|
||||||
<div className="col-md-9 col-xs-12">
|
<div className="col-md-9 col-xs-12">
|
||||||
<Books />
|
<Books data={edges} />
|
||||||
<Newsletter />
|
<Newsletter />
|
||||||
</div>
|
</div>
|
||||||
<div className="col-md-3 col-xs-12">
|
<div className="col-md-3 col-xs-12">
|
||||||
@ -43,4 +44,26 @@ const BooksPage = () => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const query = graphql`
|
||||||
|
{
|
||||||
|
allMarkdownRemark(filter: {frontmatter: {templateKey: {eq: "book"}}}) {
|
||||||
|
edges {
|
||||||
|
node {
|
||||||
|
frontmatter {
|
||||||
|
title
|
||||||
|
image {
|
||||||
|
childImageSharp {
|
||||||
|
fluid {
|
||||||
|
...GatsbyImageSharpFluid
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
html
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
export default BooksPage
|
export default BooksPage
|
||||||
|
|||||||
@ -45,6 +45,13 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.anchor {
|
||||||
|
display: block;
|
||||||
|
position: relative;
|
||||||
|
top: -150px;
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
.inner {
|
.inner {
|
||||||
border-bottom: 1px solid #EBEBEB;
|
border-bottom: 1px solid #EBEBEB;
|
||||||
padding-bottom: 15px;
|
padding-bottom: 15px;
|
||||||
|
|||||||
@ -37,3 +37,13 @@ collections:
|
|||||||
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"}
|
||||||
|
- name: 'books'
|
||||||
|
label: "Book"
|
||||||
|
folder: 'content/books'
|
||||||
|
create: true
|
||||||
|
slug: "{{year}}-{{month}}-{{day}}"
|
||||||
|
fields:
|
||||||
|
- {label: "Template key", name: "templateKey", widget: "hidden", default: "book"}
|
||||||
|
- {label: "Название книги", name: "title", widget: "string"}
|
||||||
|
- {label: "Обложка", name: "image", widget: "image"}
|
||||||
|
- {label: "Описание книги", name: "body", widget: "markdown"}
|
||||||
Loading…
x
Reference in New Issue
Block a user