fix: resolve LFX program page content rendering#7518
fix: resolve LFX program page content rendering#7518rishiraj38 wants to merge 1 commit intolayer5io:masterfrom
Conversation
Signed-off-by: Rishi Raj <rishiraj438gt@gmail.com>
|
🚀 Preview for commit 2d9ce49 at: https://69ba6d436673b75952eca60f--layer5.netlify.app |
There was a problem hiding this comment.
@rishiraj38 When using string comparison (>) works for cases like lfx-2024 vs lfx-2023, it breaks when comparing versioned vs un-versioned slugs.
For example, in JavaScript, "/programs/gsod-2024/" > "/programs/gsod/" evaluates to false (because - has a lower char code than /). This causes the older gsod page to incorrectly be set as the "latest" over gsod-2024.
|
@rishiraj38 i again verified my suggestion and i think your changes are correct. I didn't account for the fact that the slug strings don't have trailing slashes. Because of that, "/programs/gsod-2024" > "/programs/gsod" actually does evaluate to true in Javascript, so this logic perfectly solves the issue. |
For better and safer results, I believe I should parse it and then compare it to determine the latest slug. What are your thoughts? @YASHMAHAKAL |
Description
This PR Fixes an issue where /programs/lfx was showing the 2026 title but old 2025/2024 content.
Before:
gatsby-node.js was creating a /programs/lfx page for every single year in a loop, so the content was getting randomly overwritten and stuck on whatever file finished last.
After:
We now use a Map to group the files by slug, explicitly pick the newest year (like 2026), and generate the page only once. We also pass the slug to the React component to keep the dropdown UI and markdown perfectly in sync.
Notes for Reviewers
Signed commits