Skip to content

Commit a7c43cb

Browse files
Merge pull request #7518 from rishiraj38/fix/lfx-program-page
fix: resolve LFX program page content rendering
2 parents 3e228e6 + d4b44a6 commit a7c43cb

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

gatsby-node.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,12 +581,26 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
581581
});
582582
});
583583

584+
const latestProgramsBySlug = new Map();
584585
programs.forEach((program) => {
586+
const slug = program.frontmatter.programSlug;
587+
if (!latestProgramsBySlug.has(slug)) {
588+
latestProgramsBySlug.set(slug, program);
589+
} else {
590+
const currentLatest = latestProgramsBySlug.get(slug);
591+
if ((program.fields?.slug || "") > (currentLatest.fields?.slug || "")) {
592+
latestProgramsBySlug.set(slug, program);
593+
}
594+
}
595+
});
596+
597+
latestProgramsBySlug.forEach((program, slug) => {
585598
envCreatePage({
586-
path: `/programs/${program.frontmatter.programSlug}`,
599+
path: `/programs/${slug}`,
587600
component: `${MultiProgramPostTemplate}?__contentFilePath=${program.internal.contentFilePath}`,
588601
context: {
589602
program: program.frontmatter.program,
603+
slug: program.fields?.slug,
590604
},
591605
});
592606
});

0 commit comments

Comments
 (0)