Use getTopicPageUrl for Topic Discovery More About link (same method topic tags uses) - #14334
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses a production issue where Topic Discovery “More about” links sometimes render without an href due to missing topicUrl data from the BFF, by standardising URL construction via a shared utility.
Changes:
- Added a shared
getTopicPageUrlutility to build topic page URLs (relative by default; absolute when required). - Updated
TopicDiscoveryandTopicTagsto use the shared utility for consistent topic link generation (with TopicDiscovery falling back whentopicUrlis missing). - Added unit tests for
getTopicPageUrlcovering relative/absolute, variants, and customtopicsPath.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/app/lib/utilities/getTopicPageUrl/index.ts | Introduces a centralized topic URL builder (relative/absolute, variant, topicsPath). |
| src/app/lib/utilities/getTopicPageUrl/index.test.ts | Adds unit coverage for URL construction scenarios. |
| src/app/components/TopicTags/index.tsx | Replaces inline URL building with getTopicPageUrl (absolute links retained for AMP/cache safety). |
| src/app/components/TopicDiscovery/index.tsx | Uses getTopicPageUrl as a fallback when BFF topicUrl is missing; reuses the constructed URL for link + analytics. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
louisearchibald
approved these changes
Aug 21, 2026
alex-magana
approved these changes
Aug 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix for bug spotted https://bbc-tpg.slack.com/archives/C03RMKNL7GC/p1787236298096979
This pull request introduces a new utility function,
getTopicPageUrl, to centralize and standardize the construction of topic page URLs across the application. The function is now used in both theTopicDiscoveryandTopicTagscomponents, replacing previously duplicated or inconsistent URL-building logic. Comprehensive tests have also been added to ensure correct URL generation for various scenarios.Refactoring and Code Reuse:
getTopicPageUrlinsrc/app/lib/utilities/getTopicPageUrl/index.tsto generate both relative and absolute topic URLs, supporting customtopicsPath, variants, and public/private service domains.TopicDiscoveryandTopicTagscomponents to use the newgetTopicPageUrlutility, replacing their local URL-building logic with calls to this shared function for consistency and maintainability. [1] [2] [3] [4]Component Logic Updates:
TopicDiscoveryto usebuildTopicPageUrlfor constructing topic URLs, ensuring consistent link generation in both UI and analytics tracking. [1] [2] [3]TopicTagsto usebuildTopicPageUrlfor all topic tag links, removing the previous inline URL logic and ensuring absolute URLs where needed. [1] [2]Absolute or relative link paths
I retained the ability for Topic Tags to use an absolute link as this component is used on AMP pages and if we used a relative link on an AMP cache it could resolve to a different domain. This is how it was in the code already.
Topic Discovery does not show on AMP pages so we do not need an absolute link and a relative link is supposed to make testing on other environments easier due to being able to stay on the same environment when clicking (however if the renderer_env query disappears then this doesn't work anyway...)
Testing:
getTopicPageUrlcovering relative and absolute URLs, public/private domains, custom topic paths, and variant handling.…ared utilityLooking at the page this bug was found on http://localhost:7081/romania/articles/cp8xgjgrykjo?renderer_env=live
you will see that the More About links all have hrefs and lead to topic pages now. If you look on live, the 3rd and 4th Topic Tab More About links do not have an href and do not work.
Resolves JIRA:
Summary
A very high-level summary of easily-reproducible changes that can be understood by non-devs, and why these changes where made.
Code changes
Testing
Useful Links