-
Notifications
You must be signed in to change notification settings - Fork 259
WS-197-Added route to render Homepages in Next.js app #13529
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WS-197-Added route to render Homepages in Next.js app #13529
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| ws-nextjs-app/pages/[service]/homepages/handleHomepageRoute.ts | Implements server-side handler for homepage routes with data fetching, caching, and error handling |
| ws-nextjs-app/pages/[service]/homepages/handleHomepageRoute.test.ts | Adds unit tests covering success, error, and edge cases for the homepage handler |
| ws-nextjs-app/pages/[service]/[[...]].page.tsx | Integrates homepage handling into the main routing logic by adding HOME_PAGE type detection and routing |
|
We'll need to add a check for This is a bit harder to check against compared to the other routes, so I'd suggest something along the lines of using |
Can I ask how you knew to do that, as well as why does this not need to be done for article routes? |
…omepages-nextJS
I implemented this function originally, so knew it was required. If you follow through the logic in It has been done for the article routes. If you check the file you'll see Optimo and CPS ID checks that determine if its an |
Thanks for this, I meant why there doesn't need to be a check for the service? I presume it's because the CPS and Optimo IDs are checked instead? |
Ah sorry! Yea the CPS and Optimo IDs will only be used for article pages, so that's a good enough method of checking that the page is likely an 'article' page. Homepages don't have any unique identifiers or patterns we can match on other than 'service'. Thinking more about it, what you have looks good but we'll need to consider variants at the end of the pathname too. |
|
|
||
| context.res.setHeader( | ||
| 'Cache-Control', | ||
| 'public, stale-if-error=90, stale-while-revalidate=30, max-age=60', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just checked on Live and the cache-control for homepages is currently set to public, stale-if-error=300, stale-while-revalidate=120, max-age=30, so I think we should keep them like that for the migration at least.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry can you please send a link or screenshot as to where on live you found this information?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you open chrome dev tools and navigate to the 'Network' tab and refresh the page, you should see the requests for the page. You can filter by Doc to see the actual document, if you click on it in the list it should open a side panel. Under Request Headers, you should see cache-control.
| rendererEnv, | ||
| resolvedUrl: resolvedUrlWithoutQuery, | ||
| pageType: HOME_PAGE, | ||
| isAmp, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can remove isAmp from this as we don't support AMP on Homepages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry just another question, looking at the readme throughout the codebase, it seems that AMP supports frontpages which are the older versions of homepages. So they support frontpages but not homepages, is that correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be something that needs removed from the readme perhaps. I don't think we have frontpages anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it worth doing that as part of this work? Just a matter of deletions i'd imagine...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it this bit you're talking about? https://github.com/bbc/simorgh/blob/eab8bd878c95532bfadf5236d9ac3d9b5636b48f/README.md#front-pages
If so, I would rename those to Home pages and remove the AMP references and links 👍
amoore108
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks for addressing all the comments 🙏
|
@Nabeel1276 I merged in #13530 and merged its changes into here, so its change |
…omepages-nextJS
…omepages-nextJS
…omepages-nextJS
Resolves JIRA: https://bbc.atlassian.net/browse/WS-197
Summary
Before:

After:

The task at hand, adds support for homepage routes in the Next.js app by implementing a new home page route handler and integrating it into the routing system.
Key Changes:
Code changes
Developer Checklist
Testing
Ready-For-Test, Local)Ready-For-Test, Test)Ready-For-Test, Preview)Ready-For-Test, Live)Additional Testing Steps
Useful Links