Skip to content
This repository has been archived by the owner on Dec 8, 2023. It is now read-only.

Commit

Permalink
feat: Use GatsbyImage for screenshots in slick slider
Browse files Browse the repository at this point in the history
  • Loading branch information
zstix committed Jul 1, 2022
1 parent 4689710 commit f06d4b6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
12 changes: 7 additions & 5 deletions src/components/QuickstartDashboards.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import { css } from '@emotion/react';
import pluralize from 'pluralize';
import { GatsbyImage, getImage } from 'gatsby-plugin-image';
import Intro from './Intro';
import { quickstart } from '../types';
import Slider from 'react-slick';
Expand Down Expand Up @@ -99,8 +100,9 @@ const QuickstartDashboards = ({ quickstart }) => {
</p>
{renderDescription(dashboard)}
<Slider {...settings}>
{dashboard.screenshots.map((imgUrl, index) => {
{dashboard.screenshots.map((node, index) => {
const elementKey = `imgurl_${index}`;
const image = getImage(node);
return (
<div
css={css`
Expand All @@ -116,16 +118,16 @@ const QuickstartDashboards = ({ quickstart }) => {
`}
>
<a
href={imgUrl}
href={node.publicURL}
target="_blank"
rel="noreferrer"
css={css`
margin: auto;
`}
>
<img
src={imgUrl}
alt="Content cannot be displayed"
<GatsbyImage
image={image}
alt={`${dashboard.name} screenshot ${index}`}
css={css`
width: 100%;
height: 17.5rem;
Expand Down
6 changes: 5 additions & 1 deletion src/templates/QuickstartDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,11 @@ export const pageQuery = graphql`
name
screenshots {
childImageSharp {
gatsbyImageData(placeholder: BLURRED, formats: [AUTO, WEBP])
gatsbyImageData(
height: 280
placeholder: BLURRED
formats: [AUTO, WEBP]
)
}
}
}
Expand Down

0 comments on commit f06d4b6

Please sign in to comment.