Skip to content

WS-203 - Most Read pages on Next.js#13838

Merged
amoore108 merged 32 commits intolatestfrom
WS-203-most-read-nextjs
Mar 31, 2026
Merged

WS-203 - Most Read pages on Next.js#13838
amoore108 merged 32 commits intolatestfrom
WS-203-most-read-nextjs

Conversation

@amoore108
Copy link
Copy Markdown
Contributor

@amoore108 amoore108 commented Mar 26, 2026

Resolves JIRA: https://bbc.atlassian.net/browse/WS-203

Summary

Renders Most Read pages as Topic pages under the Next.js app

Note: These pages won't be using the Next.js app until routing changes are applied upstream

Code changes

  • Adds [service]/popular/read/[[...variant]] route to Next.js app
  • Fetches Topic data for Most Read page and renders Topic page component with Most Read curation
  • Adds a temporary rewrite to allow services with variants to render under this route. This can be removed once we add a permanent redirect upstream to redirect variant paths to have the variant at the end of the path

Testing

  1. Visit http://localhost:7081/pidgin/popular/read
  2. Confirm it renders data from local fixture
  3. Visit http://localhost:7081/mundo/popular/read?renderer_env=live
  4. Confirm it renders data from Live
  5. Visit http://localhost:7081/serbian/cyr/popular/read?renderer_env=live
  6. Confirm the variant path renders correctly
  7. Visit http://localhost:7081/serbian/popular/read/cyr?renderer_env=live
  8. Confirm the variant path at the end of the URL renders correctly

Useful Links

@amoore108 amoore108 self-assigned this Mar 26, 2026
@amoore108 amoore108 changed the title Ws 203 most read nextjs WS-203 - Most Read pages on Next.js Mar 26, 2026
@amoore108 amoore108 marked this pull request as ready for review March 26, 2026 14:50
Copilot AI review requested due to automatic review settings March 26, 2026 14:50
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Renders Most Read pages inside the Next.js app by treating them as Topic pages backed by a dedicated mostReadTopic identifier, including local fixture support and a temporary rewrite for variant-prefixed URLs.

Changes:

  • Added a Next.js route at [service]/popular/read/[[...variant]] that fetches Topic data (id mostReadTopic) and renders it as a Most Read page.
  • Added a temporary Next.js rewrite to support variant-in-the-middle URLs (e.g. /serbian/cyr/popular/read).
  • Updated constructPageFetchUrl (and tests) to support resolving a Topic fetch id for mostReadTopic, plus added a pidgin fixture.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
ws-nextjs-app/pages/[service]/popular/read/[[...variant]].page.tsx New SSR route for Most Read in Next.js using Topic fetch data.
ws-nextjs-app/pages/[service]/popular/read/[[...variant]].page.test.tsx Unit tests for the new Most Read route SSR props + caching header.
ws-nextjs-app/next.config.js Temporary rewrite to support services where variant appears before /popular/read.
src/app/routes/utils/constructPageFetchUrl/index.ts Special-cases Topic ID derivation for mostReadTopic.
src/app/routes/utils/constructPageFetchUrl/index.test.ts Adds coverage for the mostReadTopic construct URL behavior in test/live envs.
data/pidgin/topics/mostReadTopic.json Local fixture backing the new Most Read Topic data.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, just wanted to ask where this fixture data came from? Was it FABL?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea we added some logic in the API to return a topic page if id='mostReadTopic' is being requested: https://github.com/bbc/fabl-modules/pull/11664

Just seemed to make sense to re-use the Topics API since it handles all the fetching and data transformation for us already.

Comment on lines +85 to +86
'Cache-Control',
'public, stale-if-error=2400, stale-while-revalidate=960, max-age=240',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this come from the request headers in the network tab? If so from which page did you get this from?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea it comes from the cache-control repsonse header.

This was copied from the Topics page, so its actually using that value. I'll change it to the existing Most Read page values as they are a bit different.

Copy link
Copy Markdown
Contributor

@pvaliani pvaliani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, is this just for canonical? Noticed http://localhost:7081/mundo/popular/read.lite?renderer_env=live doesn't render

@amoore108
Copy link
Copy Markdown
Contributor Author

Looks good, is this just for canonical? Noticed http://localhost:7081/mundo/popular/read.lite?renderer_env=live doesn't render

Hmm good spot. Should be working on Lite. I'll take a look.

@pvaliani
Copy link
Copy Markdown
Contributor

Looks good, is this just for canonical? Noticed http://localhost:7081/mundo/popular/read.lite?renderer_env=live doesn't render

Hmm good spot. Should be working on Lite. I'll take a look.

Should .amp also be supported? Crossed my mind too. No worries! I'll check again once further updates are in

@pvaliani
Copy link
Copy Markdown
Contributor

pvaliani commented Mar 31, 2026

This is how .amp is looking for me just for reference. The most read items are missing
image

@amoore108
Copy link
Copy Markdown
Contributor Author

This is how .amp is looking for me just for reference. The most read items are missing

AMP will no longer be supported, but product are ok with this.

@amoore108 amoore108 merged commit 5755345 into latest Mar 31, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants