Skip to content

Commit 1a8b645

Browse files
committed
fix: restore gsoc dropdown on program pages
Signed-off-by: Rishi Raj <rishiraj438gt@gmail.com>
1 parent 5010d56 commit 1a8b645

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

gatsby-node.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,9 +328,10 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
328328
programs.forEach((program) => {
329329
envCreatePage({
330330
path: program.fields.slug,
331-
component: `${ProgramPostTemplate}?__contentFilePath=${program.internal.contentFilePath}`,
331+
component: `${MultiProgramPostTemplate}?__contentFilePath=${program.internal.contentFilePath}`,
332332
context: {
333333
slug: program.fields.slug,
334+
program: program.frontmatter.program,
334335
},
335336
});
336337
});

src/sections/Careers/Careers-Programs-single/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const ProgramsSingle = ({ data, children, options, setActiveOption, activeOption
3030
styles={selectStyles}
3131
options={options}
3232
value={options[activeOption]}
33-
onChange={(e) => setActiveOption(() => e.value)}
33+
onChange={(e) => setActiveOption(e.value)}
3434
theme={dropdownTheme}
3535
/>}
3636
</div>

src/templates/program-multiple.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,13 @@ export const query = graphql`query ProgramByName($program: String!) {
2323
}
2424
}`;
2525

26-
const ProgramsPage = ({ data, children }) => {
27-
const [activeOption] = useState(0);
26+
const ProgramsPage = ({ data, children, pageContext }) => {
2827
const programs = data.allMdx.nodes;
2928
const { navigate } = require("gatsby");
3029

30+
const initialIndex = programs.findIndex((program) => program.fields.slug === pageContext.slug);
31+
const [activeOption] = useState(initialIndex !== -1 ? initialIndex : 0);
32+
3133
const options = programs.map((program) => {
3234
let optionItem = new Object();
3335
optionItem.label = program.frontmatter.title;

0 commit comments

Comments
 (0)