Skip to content

Commit

Permalink
Fix gallery not populating on project pages
Browse files Browse the repository at this point in the history
  • Loading branch information
adamgraham committed Jul 8, 2023
1 parent df0ba4a commit 75dba68
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 28 deletions.
7 changes: 1 addition & 6 deletions src/components/GalleryPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@ const GalleryPage = ({ category, gallery, location }) => {
title: `Adam Graham • ${titleCase(category)}`,
}}
>
<Gallery
category={category}
gallery={gallery}
setSlideIndex={setSlideIndex}
slideIndex={slideIndex}
/>
<Gallery />
</Page>
</GalleryContext.Provider>
);
Expand Down
38 changes: 21 additions & 17 deletions src/components/ProjectPage.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,34 @@
import PropTypes from 'prop-types';
import React from 'react';
import React, { useState } from 'react';
import GalleryContext, { useContext } from './GalleryContext';
import Page from './Page';
import Project, { ProjectProps } from './Project';
import { SlideProps } from './Slide';
import { getSessionIndex } from '../utils/session';

const ProjectPage = ({ gallery, location, project }) => {
const metadata = {
url: `https://adamgraham.io/${project.category}/${project.id}`,
title: `Adam Graham • ${project.title}`,
description: project.description_short || project.description,
image: project.image && project.image.sharp.original.src,
};
const ProjectPage = ({ category, gallery, location, project }) => {
const [slideIndex, setSlideIndex] = useState(getSessionIndex(category));
const context = useContext(category, gallery, slideIndex, setSlideIndex);
return (
<Page
category={project.category}
gallery={gallery}
id={project.id}
location={location}
metadata={metadata}
>
<Project project={project} />
</Page>
<GalleryContext.Provider value={context}>
<Page
id={project.id}
location={location}
metadata={{
url: `https://adamgraham.io/${project.category}/${project.id}`,
title: `Adam Graham • ${project.title}`,
description: project.description_short || project.description,
image: project.image && project.image.sharp.original.src,
}}
>
<Project project={project} />
</Page>
</GalleryContext.Provider>
);
};

ProjectPage.propTypes = {
category: PropTypes.string,
gallery: PropTypes.arrayOf(SlideProps),
location: PropTypes.object,
project: ProjectProps,
Expand Down
7 changes: 6 additions & 1 deletion src/pages/art/{ArtJson.jsonId}.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,12 @@ const Art = ({ data, location }) => {
const { project } = data;
const { gallery } = data.json;
return (
<ProjectPage gallery={gallery} location={location} project={project} />
<ProjectPage
category={project.category}
gallery={gallery}
location={location}
project={project}
/>
);
};

Expand Down
7 changes: 6 additions & 1 deletion src/pages/games/{GamesJson.jsonId}.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,12 @@ const Game = ({ data, location }) => {
const { project } = data;
const { gallery } = data.json;
return (
<ProjectPage gallery={gallery} location={location} project={project} />
<ProjectPage
category={project.category}
gallery={gallery}
location={location}
project={project}
/>
);
};

Expand Down
7 changes: 6 additions & 1 deletion src/pages/presentations/{PresentationsJson.jsonId}.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,12 @@ const Presentation = ({ data, location }) => {
const { project } = data;
const { gallery } = data.json;
return (
<ProjectPage gallery={gallery} location={location} project={project} />
<ProjectPage
category={project.category}
gallery={gallery}
location={location}
project={project}
/>
);
};

Expand Down
7 changes: 6 additions & 1 deletion src/pages/tech/{TechJson.jsonId}.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,12 @@ const Tech = ({ data, location }) => {
const { project } = data;
const { gallery } = data.json;
return (
<ProjectPage gallery={gallery} location={location} project={project} />
<ProjectPage
category={project.category}
gallery={gallery}
location={location}
project={project}
/>
);
};

Expand Down
7 changes: 6 additions & 1 deletion src/pages/websites/{WebsitesJson.jsonId}.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,12 @@ const Website = ({ data, location }) => {
const { project } = data;
const { gallery } = data.json;
return (
<ProjectPage gallery={gallery} location={location} project={project} />
<ProjectPage
category={project.category}
gallery={gallery}
location={location}
project={project}
/>
);
};

Expand Down

0 comments on commit 75dba68

Please sign in to comment.