mirror of
https://github.com/sergeyyarkov/devthread.ru.git
synced 2026-10-11 02:09:04 +03:00
pathname to view counter
This commit is contained in:
parent
dc739b064d
commit
dd773ee474
@ -6,6 +6,7 @@ import ViewCounter from '../ViewCounter/ViewCounter'
|
|||||||
import useSiteMetadataQuery from '../../hooks/useSiteMetadataQuery'
|
import useSiteMetadataQuery from '../../hooks/useSiteMetadataQuery'
|
||||||
import slugify from '../../helpers/slugify'
|
import slugify from '../../helpers/slugify'
|
||||||
import { Link } from 'gatsby'
|
import { Link } from 'gatsby'
|
||||||
|
import { useLocation } from '@reach/router'
|
||||||
|
|
||||||
import ViewsIcon from '../../images/views-icon.svg'
|
import ViewsIcon from '../../images/views-icon.svg'
|
||||||
import VkIcon from '../../images/vk-icon.svg'
|
import VkIcon from '../../images/vk-icon.svg'
|
||||||
@ -14,6 +15,8 @@ import FacebookIcon from '../../images/facebook-icon__large.svg'
|
|||||||
|
|
||||||
const Article = ({ data: { slug, keywords, title, image, description, category, tags, time, date }, html }) => {
|
const Article = ({ data: { slug, keywords, title, image, description, category, tags, time, date }, html }) => {
|
||||||
const { siteMetadata: { siteUrl } } = useSiteMetadataQuery()
|
const { siteMetadata: { siteUrl } } = useSiteMetadataQuery()
|
||||||
|
const { pathname } = useLocation()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<SEO title={title} titleTemplate={false} keywords={keywords.join(', ')} description={description} image={`${siteUrl}${image.childImageSharp.fluid.src}`} type='article' />
|
<SEO title={title} titleTemplate={false} keywords={keywords.join(', ')} description={description} image={`${siteUrl}${image.childImageSharp.fluid.src}`} type='article' />
|
||||||
@ -26,7 +29,7 @@ const Article = ({ data: { slug, keywords, title, image, description, category,
|
|||||||
</div>
|
</div>
|
||||||
<div className="article-info__views">
|
<div className="article-info__views">
|
||||||
<ViewsIcon />
|
<ViewsIcon />
|
||||||
<ViewCounter id={slug} />
|
<ViewCounter id={pathname} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="right-info">
|
<div className="right-info">
|
||||||
|
|||||||
@ -26,7 +26,7 @@ collections:
|
|||||||
label: "Category"
|
label: "Category"
|
||||||
folder: 'content/categories'
|
folder: 'content/categories'
|
||||||
create: true
|
create: true
|
||||||
slug: "{{year}}-{{month}}-{{day}}"
|
slug: "{{slug}}"
|
||||||
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"}
|
||||||
@ -34,7 +34,7 @@ collections:
|
|||||||
label: "Tag"
|
label: "Tag"
|
||||||
folder: 'content/tags'
|
folder: 'content/tags'
|
||||||
create: true
|
create: true
|
||||||
slug: "{{year}}-{{month}}-{{day}}"
|
slug: "{{slug}}"
|
||||||
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"}
|
||||||
@ -42,7 +42,7 @@ collections:
|
|||||||
label: "Book"
|
label: "Book"
|
||||||
folder: 'content/books'
|
folder: 'content/books'
|
||||||
create: true
|
create: true
|
||||||
slug: "{{year}}-{{month}}-{{day}}"
|
slug: "{{slug}}"
|
||||||
fields:
|
fields:
|
||||||
- {label: "Template key", name: "templateKey", widget: "hidden", default: "book"}
|
- {label: "Template key", name: "templateKey", widget: "hidden", default: "book"}
|
||||||
- {label: "Название книги", name: "title", widget: "string"}
|
- {label: "Название книги", name: "title", widget: "string"}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user