mirror of
https://github.com/sergeyyarkov/devthread.ru.git
synced 2026-10-11 10:19:13 +03:00
amp images fix
This commit is contained in:
parent
69a95f70a2
commit
bd6150eac9
@ -18,6 +18,7 @@ import FacebookIcon from "../../images/facebook-icon__large.svg"
|
|||||||
const Article = ({
|
const Article = ({
|
||||||
data: { slug, title, image, description, category, tags, time, date },
|
data: { slug, title, image, description, category, tags, time, date },
|
||||||
html,
|
html,
|
||||||
|
amp
|
||||||
}) => {
|
}) => {
|
||||||
const {
|
const {
|
||||||
siteMetadata: {
|
siteMetadata: {
|
||||||
@ -92,12 +93,18 @@ const Article = ({
|
|||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
<div className="article-image">
|
<div className="article-image">
|
||||||
<Img
|
{!amp
|
||||||
loading="eager"
|
? <Img
|
||||||
fadeIn={false}
|
loading="eager"
|
||||||
fluid={image.childImageSharp.fluid}
|
fadeIn={false}
|
||||||
alt={title}
|
fluid={image.childImageSharp.fluid}
|
||||||
/>
|
alt={title}
|
||||||
|
/>
|
||||||
|
: <img
|
||||||
|
src={image.childImageSharp.fluid.src}
|
||||||
|
height='350'
|
||||||
|
/>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
<div className="article-inner inner">
|
<div className="article-inner inner">
|
||||||
<div dangerouslySetInnerHTML={{ __html: html }}></div>
|
<div dangerouslySetInnerHTML={{ __html: html }}></div>
|
||||||
|
|||||||
@ -6,17 +6,21 @@ import { Link } from "gatsby"
|
|||||||
|
|
||||||
const ArticleCard = ({
|
const ArticleCard = ({
|
||||||
data: { slug, title, image, category, description, tags },
|
data: { slug, title, image, category, description, tags },
|
||||||
|
amp
|
||||||
}) => {
|
}) => {
|
||||||
return (
|
return (
|
||||||
<article className="article-card">
|
<article className="article-card">
|
||||||
<div className="article-card__image">
|
<div className="article-card__image">
|
||||||
<Link to={`/article/${slug}/`}>
|
<Link to={`/article/${slug}/`}>
|
||||||
<Img
|
{!amp
|
||||||
loading="eager"
|
? <Img
|
||||||
fadeIn={false}
|
loading="eager"
|
||||||
fluid={image.childImageSharp.fluid}
|
fadeIn={false}
|
||||||
alt={title}
|
fluid={image.childImageSharp.fluid}
|
||||||
/>
|
alt={title}
|
||||||
|
/>
|
||||||
|
: <img src={image.childImageSharp.fluid.src} height='380' />
|
||||||
|
}
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
<div className="article-card__heading">
|
<div className="article-card__heading">
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import { useLocation } from "@reach/router"
|
|||||||
import useMoreArticlesQuery from "../../../hooks/useMoreArticlesQuery"
|
import useMoreArticlesQuery from "../../../hooks/useMoreArticlesQuery"
|
||||||
import ArticleCard from "../ArticleCard/ArticleCard"
|
import ArticleCard from "../ArticleCard/ArticleCard"
|
||||||
|
|
||||||
const MoreArticles = () => {
|
const MoreArticles = ({ amp }) => {
|
||||||
const { edges } = useMoreArticlesQuery()
|
const { edges } = useMoreArticlesQuery()
|
||||||
const { pathname } = useLocation()
|
const { pathname } = useLocation()
|
||||||
const query = pathname.split("/")[pathname.split("/").length - 1]
|
const query = pathname.split("/")[pathname.split("/").length - 1]
|
||||||
@ -19,7 +19,7 @@ const MoreArticles = () => {
|
|||||||
.sort(() => Math.random() - 0.5)
|
.sort(() => Math.random() - 0.5)
|
||||||
.map(({ node }, i) => {
|
.map(({ node }, i) => {
|
||||||
if (i < 4) {
|
if (i < 4) {
|
||||||
return <ArticleCard key={i} data={node.frontmatter} />
|
return <ArticleCard key={i} data={node.frontmatter} amp={amp} />
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
})}
|
})}
|
||||||
|
|||||||
@ -32,9 +32,9 @@ const articleTemplateAmp = ({
|
|||||||
<Grid fluid style={{ maxWidth: 800 }}>
|
<Grid fluid style={{ maxWidth: 800 }}>
|
||||||
<Row>
|
<Row>
|
||||||
<Col xs={12}>
|
<Col xs={12}>
|
||||||
<Article data={frontmatter} html={html} />
|
<Article data={frontmatter} html={html} amp={true} />
|
||||||
<Newsletter />
|
<Newsletter />
|
||||||
<MoreArticles />
|
<MoreArticles amp={true} />
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user