mirror of
https://github.com/sergeyyarkov/devthread.ru.git
synced 2026-10-11 10:19:13 +03:00
og & data
This commit is contained in:
parent
6c04635a9b
commit
6e1469ca63
@ -7,9 +7,10 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
siteMetadata: {
|
siteMetadata: {
|
||||||
title: 'devthread.ru',
|
title: 'devthread.ru',
|
||||||
|
siteName: 'Cборник статей и руководств - devthread.ru',
|
||||||
titleTemplate: '%s · статьи и руководства по веб-разработке',
|
titleTemplate: '%s · статьи и руководства по веб-разработке',
|
||||||
description: 'сборник статей и руководств по тематике веб-разработки и IT для того чтобы помочь вам',
|
description: 'Cборник статей и руководств по тематике веб-разработки и IT для того чтобы помочь вам',
|
||||||
url: 'https://devthread.ru',
|
url: 'https://devthread.netlify.app',
|
||||||
menuLinks: [
|
menuLinks: [
|
||||||
{
|
{
|
||||||
name: 'Статьи',
|
name: 'Статьи',
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import React from 'react';
|
|||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
import SEO from '../SEO/SEO'
|
import SEO from '../SEO/SEO'
|
||||||
import Img from "gatsby-image"
|
import Img from "gatsby-image"
|
||||||
|
import useSiteMetadataQuery from '../../hooks/useSiteMetadataQuery'
|
||||||
import slugify from '../../helpers/slugify'
|
import slugify from '../../helpers/slugify'
|
||||||
import { Link } from 'gatsby'
|
import { Link } from 'gatsby'
|
||||||
import './Article.scss'
|
import './Article.scss'
|
||||||
@ -12,9 +13,11 @@ import TwitterIcon from '../../images/twitter-icon__large.svg'
|
|||||||
import FacebookIcon from '../../images/facebook-icon__large.svg'
|
import FacebookIcon from '../../images/facebook-icon__large.svg'
|
||||||
|
|
||||||
const Article = ({ data: { slug, title, image, description, category, tags, time, date }, html }) => {
|
const Article = ({ data: { slug, title, image, description, category, tags, time, date }, html }) => {
|
||||||
|
const { siteMetadata: { siteUrl } } = useSiteMetadataQuery()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<SEO title={title} description={description} />
|
<SEO title={title} description={description} image={`${siteUrl}${image.childImageSharp.fluid.src}`} type='article' />
|
||||||
<div className="article">
|
<div className="article">
|
||||||
<article>
|
<article>
|
||||||
<div className="article-info">
|
<div className="article-info">
|
||||||
@ -42,13 +45,13 @@ const Article = ({ data: { slug, title, image, description, category, tags, time
|
|||||||
<div className="article-share">
|
<div className="article-share">
|
||||||
<span>Поделиться:</span>
|
<span>Поделиться:</span>
|
||||||
<div className="article-share__social">
|
<div className="article-share__social">
|
||||||
<a href={`/article/${slug}`}>
|
<a href={`https://vk.com/share.php?url=${siteUrl}/article/${slug}&title=${title}&image=${siteUrl}${image.childImageSharp.fluid.src}`} target='_blank' rel='noreferrer'>
|
||||||
<VkIcon />
|
<VkIcon />
|
||||||
</a>
|
</a>
|
||||||
<a href={`/article/${slug}`}>
|
<a href={`https://twitter.com/intent/tweet?text=${title}&url=${siteUrl}/article/${slug}&image=${siteUrl}${image.childImageSharp.fluid.src}`} target='_blank' rel='noreferrer'>
|
||||||
<TwitterIcon />
|
<TwitterIcon />
|
||||||
</a>
|
</a>
|
||||||
<a href={`/article/${slug}`}>
|
<a href={`https://www.facebook.com/sharer/sharer.php?u=${siteUrl}/article/${slug}&t=${title}`} target='_blank' rel='noreferrer'>
|
||||||
<FacebookIcon />
|
<FacebookIcon />
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -4,12 +4,15 @@ import PropTypes from 'prop-types'
|
|||||||
import { Helmet } from 'react-helmet'
|
import { Helmet } from 'react-helmet'
|
||||||
import { useLocation } from '@reach/router'
|
import { useLocation } from '@reach/router'
|
||||||
|
|
||||||
const SEO = ({ title, description }) => {
|
const SEO = ({ title, description, image, type }) => {
|
||||||
const { pathname } = useLocation()
|
const { pathname } = useLocation()
|
||||||
const { siteMetadata } = useSiteMetadataQuery()
|
const { siteMetadata } = useSiteMetadataQuery()
|
||||||
|
|
||||||
const seo = {
|
const seo = {
|
||||||
title: title || siteMetadata.title,
|
title: title || siteMetadata.title,
|
||||||
|
siteName: siteMetadata.siteName,
|
||||||
|
type: type || 'website',
|
||||||
|
image: image || 'custom image url...',
|
||||||
description: description || siteMetadata.description,
|
description: description || siteMetadata.description,
|
||||||
url: `${siteMetadata.siteUrl}${pathname}`
|
url: `${siteMetadata.siteUrl}${pathname}`
|
||||||
}
|
}
|
||||||
@ -17,7 +20,16 @@ const SEO = ({ title, description }) => {
|
|||||||
return (
|
return (
|
||||||
<Helmet title={seo.title} titleTemplate={siteMetadata.titleTemplate}>
|
<Helmet title={seo.title} titleTemplate={siteMetadata.titleTemplate}>
|
||||||
<meta name="description" content={seo.description} />
|
<meta name="description" content={seo.description} />
|
||||||
|
<meta property='og:locale' content='ru_RU' />
|
||||||
<meta property="og:url" content={seo.url} />
|
<meta property="og:url" content={seo.url} />
|
||||||
|
<meta property='og:site_name' content={seo.siteName}
|
||||||
|
/>
|
||||||
|
{seo.type && (
|
||||||
|
<meta property='og:type' content={seo.type} />
|
||||||
|
)}
|
||||||
|
{seo.image && (
|
||||||
|
<meta property="og:image" content={seo.image} />
|
||||||
|
)}
|
||||||
{seo.description && (
|
{seo.description && (
|
||||||
<meta property="og:description" content={seo.description} />
|
<meta property="og:description" content={seo.description} />
|
||||||
)}
|
)}
|
||||||
|
|||||||
@ -7,6 +7,7 @@ const useSiteMetadata = () => {
|
|||||||
siteMetadata {
|
siteMetadata {
|
||||||
title
|
title
|
||||||
titleTemplate
|
titleTemplate
|
||||||
|
siteName
|
||||||
description
|
description
|
||||||
siteUrl: url
|
siteUrl: url
|
||||||
menuLinks {
|
menuLinks {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user