Skip to content
This repository has been archived by the owner on Feb 16, 2021. It is now read-only.

Traced/primitive svg previews #8

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module.exports = {
pathPrefix: '/gatsby-contentful-starter',
plugins: [
'gatsby-transformer-remark',
'gatsby-transformer-sqip',
'gatsby-plugin-react-helmet',
{
resolve: 'gatsby-source-contentful',
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
},
"dependencies": {
"contentful-import": "^6.2.0",
"gatsby-image": "^1.0.39",
"gatsby-link": "^1.6.34",
"gatsby-plugin-react-helmet": "^1.0.8",
"gatsby-source-contentful": "^1.3.38",
Expand Down
10 changes: 9 additions & 1 deletion src/components/article-preview.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
import React from 'react'
import styles from './article-preview.module.css'
import Link from 'gatsby-link'
import Img from 'gatsby-image'

export default ({ article }) => (
<div className={styles.preview}>
<img src={`${article.heroImage.file.url}?fit=scale&w=350&h=196`} alt="" />
<Img
className={styles.heroImage}
sizes={{
...article.heroImage.responsiveSizes,
base64: article.heroImage.sqip
}}
alt=""
/>
<h3 className={styles.previewTitle}>
<Link to={`/blog/${article.slug}`}>{article.title}</Link>
</h3>
Expand Down
8 changes: 6 additions & 2 deletions src/components/hero.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import React from 'react'
import Img from "gatsby-image";
import styles from './hero.module.css'

export default ({ person }) => (
<div className={styles.hero}>
<img
<Img
className={styles.heroImage}
src={`${person.node.image.file.url}?w=1180&h=600&fit=pad&bg=rgb:000000`}
sizes={{
...person.node.image.responsiveSizes,
base64: person.node.image.sqip
}}
alt=""
/>
<div className={styles.heroDetails}>
Expand Down
14 changes: 13 additions & 1 deletion src/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,13 @@ export const pageQuery = graphql`
heroImage {
file {
url
}
},
responsiveSizes(maxWidth: 350, maxHeight: 196, resizingBehavior: SCALE) {
srcSet,
sizes,
aspectRatio
},
sqip(numberOfPrimitives: 25, blur: 0, width: 350, height: 196, resizingBehavior: SCALE)
}
description {
childMarkdownRemark {
Expand All @@ -69,6 +75,12 @@ export const pageQuery = graphql`
url
fileName
contentType
},
sqip(numberOfPrimitives: 50, blur: 1, width: 1180, height: 480, resizingBehavior: PAD, background: "rgb:000000"),
responsiveSizes(maxWidth: 1180, maxHeight: 480, resizingBehavior: PAD, background: "rgb:000000") {
srcSet,
sizes,
aspectRatio
}
}
}
Expand Down