Skip to content
Merged
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
17 changes: 10 additions & 7 deletions src/templates/challenge.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,21 @@ import PiCharacter from '../images/characters/PiGuy_2.mini.svg';
import SemiColonCharacter from '../images/characters/SemiColon_2.mini.svg';

const Challenge = ({ data }) => {
const { challenge, contributionPlaceholderImage, challengePlaceholderImage } =
const { challenge, coverImage, challengePlaceholderImage } =
data;
// generic placeholder for challenge videos, collage of screenshots of challenge thumbnails
const challengesPlaceholder = challengePlaceholderImage
? challengePlaceholderImage.childImageSharp.gatsbyImageData
: null;
const contributionsPlaceholder = contributionPlaceholderImage
? contributionPlaceholderImage.childImageSharp.gatsbyImageData
// cover image for the challenge, fallbacks to placeholder
const cover = coverImage
? coverImage.childImageSharp.gatsbyImageData
: challengesPlaceholder;
return (
<Layout
title={challenge.title}
description={challenge.description}
image={contributionsPlaceholder}>
image={cover}>
<Breadcrumbs
className={css.breadcrumbs}
breadcrumbs={[
Expand All @@ -49,7 +51,7 @@ const Challenge = ({ data }) => {
video={challenge}
variant="cyan"
url={`/challenges/${challenge.slug}`}
placeholderImage={contributionsPlaceholder}
placeholderImage={cover}
/>
</main>

Expand All @@ -66,7 +68,8 @@ const Challenge = ({ data }) => {

<PassengerShowcasePanel
contributions={challenge.showcase}
placeholderImage={contributionsPlaceholder}
// fallback to challenge cover image if no showcase cover image exists
placeholderImage={cover}
submitButtonState={{ track: 'challenges', video: challenge.slug }}
/>

Expand Down Expand Up @@ -190,7 +193,7 @@ export const query = graphql`
}
}
}
contributionPlaceholderImage: file(
coverImage: file(
sourceInstanceName: { eq: "challenges" }
extension: { in: ["jpg", "png"] }
relativeDirectory: { eq: $slug }
Expand Down
18 changes: 16 additions & 2 deletions src/templates/guide.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,20 @@ const useLocalImages = (images) => {
};

const Guide = ({ data, children }) => {
const { mdx, images } = data;
const { mdx, images, coverImage } = data;

const localImages = useLocalImages(images.nodes);

// cover image for the guide, falls back to final placeholder image
const guideCover = coverImage
? coverImage.childImageSharp.gatsbyImageData
: localImages['placeholder.png'];

return (
<Layout
title={mdx.frontmatter.title}
description={mdx.frontmatter.description}
image={localImages['placeholder.png']}>
image={guideCover}>
<Breadcrumbs
className={css.breadcrumbs}
breadcrumbs={[
Expand Down Expand Up @@ -243,6 +248,15 @@ export const query = graphql`
}
}
}
coverImage: file(
sourceInstanceName: { eq: "guides" }
extension: { in: ["jpg", "png"] }
name: { eq: $slug }
) {
childImageSharp {
gatsbyImageData
}
}
}
`;

Expand Down
50 changes: 41 additions & 9 deletions src/templates/track-video.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,44 @@ const Track = ({ pageContext, data }) => {
const {
track,
video,
contributionPlaceholderImage,
coverImage,
videoPlaceHolderImage,
challengePlaceholderImage
} = data;

const contributionsPlaceholder = contributionPlaceholderImage
? contributionPlaceholderImage.childImageSharp.gatsbyImageData
const placeholderMainTrackImage =
data.placeholderMainTrackImage.childImageSharp.gatsbyImageData;
const placeholderSideTrackImage =
data.placeholderSideTrackImage.childImageSharp.gatsbyImageData;
const trackPlaceholder =
track.type === 'main'
? placeholderMainTrackImage
: placeholderSideTrackImage;

// cover image for the video, falls back to final placeholder image
// (used as placeholder for contributions)
const contributionsPlaceholder = coverImage
? coverImage.childImageSharp.gatsbyImageData
: videoPlaceHolderImage
? videoPlaceHolderImage.childImageSharp.gatsbyImageData
: null;

// generic placeholder for challenge videos, collage of screenshots of challenge thumbnails
const challengesPlaceholder =
challengePlaceholderImage.childImageSharp.gatsbyImageData;

const { trackPosition, isTrackPage } = pageContext;

// cover image for the track, falls back to track placeholder image
const trackImage = track.cover
? track.cover.file.childImageSharp.gatsbyImageData
: contributionsPlaceholder;
: trackPlaceholder;

const videoImage = video.cover
? video.cover.file.childImageSharp.gatsbyImageData
// cover image for the video, falls back to track cover image
const videoImage = coverImage
? coverImage.childImageSharp.gatsbyImageData
: trackImage;

const { trackPosition, isTrackPage } = pageContext;

return (
<Layout
title={isTrackPage ? track.title : video.title}
Expand Down Expand Up @@ -294,7 +308,7 @@ export const query = graphql`
}
}
}
contributionPlaceholderImage: file(
coverImage: file(
sourceInstanceName: { eq: $source }
extension: { in: ["jpg", "png"] }
relativeDirectory: { eq: $videoSlug }
Expand Down Expand Up @@ -324,6 +338,24 @@ export const query = graphql`
gatsbyImageData
}
}
placeholderMainTrackImage: file(
sourceInstanceName: { eq: "main-tracks" }
extension: { in: ["jpg", "png"] }
name: { eq: "placeholder" }
) {
childImageSharp {
gatsbyImageData
}
}
placeholderSideTrackImage: file(
sourceInstanceName: { eq: "side-tracks" }
extension: { in: ["jpg", "png"] }
name: { eq: "placeholder" }
) {
childImageSharp {
gatsbyImageData
}
}
}
`;

Expand Down