Skip to content

Commit 2d9ce49

Browse files
committed
fix: resolve LFX program page content rendering
Signed-off-by: Rishi Raj <rishiraj438gt@gmail.com>
1 parent 567528f commit 2d9ce49

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
@@ -565,12 +565,26 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
565565
});
566566
});
567567

568+
const latestProgramsBySlug = new Map();
568569
programs.forEach((program) => {
570+
const slug = program.frontmatter.programSlug;
571+
if (!latestProgramsBySlug.has(slug)) {
572+
latestProgramsBySlug.set(slug, program);
573+
} else {
574+
const currentLatest = latestProgramsBySlug.get(slug);
575+
if ((program.fields?.slug || "") > (currentLatest.fields?.slug || "")) {
576+
latestProgramsBySlug.set(slug, program);
577+
}
578+
}
579+
});
580+
581+
latestProgramsBySlug.forEach((program, slug) => {
569582
envCreatePage({
570-
path: `/programs/${program.frontmatter.programSlug}`,
583+
path: `/programs/${slug}`,
571584
component: `${MultiProgramPostTemplate}?__contentFilePath=${program.internal.contentFilePath}`,
572585
context: {
573586
program: program.frontmatter.program,
587+
slug: program.fields?.slug,
574588
},
575589
});
576590
});

0 commit comments

Comments
 (0)