diff --git a/packages/ts-components/src/components/recommended-articles/__tests__/formatters.test.tsx b/packages/ts-components/src/components/recommended-articles/__tests__/formatters.test.tsx index 9bf8f4b8ea5..0de6f5ac431 100644 --- a/packages/ts-components/src/components/recommended-articles/__tests__/formatters.test.tsx +++ b/packages/ts-components/src/components/recommended-articles/__tests__/formatters.test.tsx @@ -23,7 +23,7 @@ const expectedArticles = [ summary: 'How is your bank balance? Even if the cost of living crisis doesn’t constitute a crisis for you, you’ll have noticed that you’re suddenly paying more for and what felt reasonable may now...', url: - 'https://www.thetimes.co.uk/article/save-or-splurge-what-experts-spend-their-own-money-on-tdd65qlj6' + 'l1/l2/article/save-or-splurge-what-experts-spend-their-own-money-on-tdd65qlj6' }, { byline: '', @@ -42,8 +42,7 @@ const expectedArticles = [ label: 'Obituary', summary: 'On August 1, 1981, Major Ian Crooke, the operations officer of 22 Special Air Service in Hereford, received a telephone call from London. A Marxist coup d’état was taking place in the former British...', - url: - 'https://www.thetimes.co.uk/article/lieutenant-colonel-ian-crooke-obituary-t0b890wgp' + url: 'l1/l2/article/lieutenant-colonel-ian-crooke-obituary-t0b890wgp' }, { byline: 'Patrick Maguire', @@ -62,8 +61,7 @@ const expectedArticles = [ label: 'RED BOX | PATRICK MAGUIRE', summary: 'Worse than May. Worse than Major. As bad as Thatcher. of his own MPs, far more than even the most pessimistic whip predicted this time yesterday. Can Boris...', - url: - 'https://www.thetimes.co.uk/article/is-the-party-over-for-boris-johnson-k8s0jxv6r' + url: 'l1/l2/article/is-the-party-over-for-boris-johnson-k8s0jxv6r' } ]; diff --git a/packages/ts-components/src/components/recommended-articles/formatters.ts b/packages/ts-components/src/components/recommended-articles/formatters.ts index b3bf2adf36c..54b0b461f8c 100644 --- a/packages/ts-components/src/components/recommended-articles/formatters.ts +++ b/packages/ts-components/src/components/recommended-articles/formatters.ts @@ -31,6 +31,7 @@ type Article = { bylines?: Byline[]; summary?: Summary; media?: Media; + categoryPath: string; }; // HELPERS @@ -66,7 +67,7 @@ const getImage = (media?: Media) => { const formatArticle = (article: Article): SliceArticle => { return { - url: article.url, + url: article.categoryPath, label: article.label, byline: getBylines(article.bylines), headline: article.headline, diff --git a/packages/ts-components/src/fixtures/preview-data/recommended-articles.ts b/packages/ts-components/src/fixtures/preview-data/recommended-articles.ts index c53f1b91929..d459f93e42d 100644 --- a/packages/ts-components/src/fixtures/preview-data/recommended-articles.ts +++ b/packages/ts-components/src/fixtures/preview-data/recommended-articles.ts @@ -4,6 +4,8 @@ export default { { url: 'https://www.thetimes.co.uk/article/save-or-splurge-what-experts-spend-their-own-money-on-tdd65qlj6', + categoryPath: + 'l1/l2/article/save-or-splurge-what-experts-spend-their-own-money-on-tdd65qlj6', slug: 'save-or-splurge-what-experts-spend-their-own-money-on', label: null, headline: 'Save or splurge: what experts spend their own money on', @@ -51,6 +53,8 @@ export default { { url: 'https://www.thetimes.co.uk/article/lieutenant-colonel-ian-crooke-obituary-t0b890wgp', + categoryPath: + 'l1/l2/article/lieutenant-colonel-ian-crooke-obituary-t0b890wgp', slug: 'lieutenant-colonel-ian-crooke-obituary', label: 'Obituary', headline: 'Lieutenant Colonel Ian Crooke', @@ -78,6 +82,8 @@ export default { { url: 'https://www.thetimes.co.uk/article/is-the-party-over-for-boris-johnson-k8s0jxv6r', + categoryPath: + 'l1/l2/article/is-the-party-over-for-boris-johnson-k8s0jxv6r', slug: 'is-the-party-over-for-boris-johnson', label: 'RED BOX | PATRICK MAGUIRE', headline: 'Is the party over for Johnson?', @@ -118,6 +124,8 @@ export default { { url: 'https://www.thetimes.co.uk/article/quentin-letts-a-pm-his-party-and-the-country-left-firmly-in-limp-on-territory-klvfgrj8g', + categoryPath: + 'l1/l2/article/quentin-letts-a-pm-his-party-and-the-country-left-firmly-in-limp-on-territory-klvfgrj8g', slug: 'quentin-letts-a-pm-his-party-and-the-country-left-firmly-in-limp-on-territory', label: 'Political Sketch', @@ -152,6 +160,8 @@ export default { { url: 'https://www.thetimes.co.uk/article/boris-johnson-should-look-for-an-honourable-exit-7fkgkl2rq', + categoryPath: + 'l1/l2/article/boris-johnson-should-look-for-an-honourable-exit-7fkgkl2rq', slug: 'boris-johnson-should-look-for-an-honourable-exit', label: 'WILLIAM HAGUE | COMMENT', headline: 'Hague: Johnson should look for an honourable exit', @@ -184,6 +194,8 @@ export default { { url: 'https://www.thetimes.co.uk/article/carrie-johnson-and-hard-times-at-no-10-hfmkr8ssn', + categoryPath: + 'l1/l2/article/carrie-johnson-and-hard-times-at-no-10-hfmkr8ssn', slug: 'carrie-johnson-and-hard-times-at-no-10', label: 'POLITICS', headline: 'Carrie Johnson and hard times at No 10', @@ -216,6 +228,8 @@ export default { { url: 'https://www.thetimes.co.uk/article/dead-man-walking-times-commentators-give-their-verdicts-boris-johnson-confidence-vote-0f59md3bt', + categoryPath: + 'l1/l2/article/dead-man-walking-times-commentators-give-their-verdicts-boris-johnson-confidence-vote-0f59md3bt', slug: 'dead-man-walking-times-commentators-give-their-verdicts-boris-johnson-confidence-vote', label: 'Politics', @@ -269,6 +283,7 @@ export default { { url: 'https://www.thetimes.co.uk/article/margot-heuman-obituary-9fdm8h3hr', + categoryPath: 'l1/l2/article/margot-heuman-obituary-9fdm8h3hr', slug: 'margot-heuman-obituary', label: 'Obituary', headline: 'Margot Heuman', @@ -296,6 +311,8 @@ export default { { url: 'https://www.thetimes.co.uk/article/the-times-view-on-tory-confidence-in-boris-johnson-pyrrhic-victory-wl5fl2jb2', + categoryPath: + 'l1/l2/article/the-times-view-on-tory-confidence-in-boris-johnson-pyrrhic-victory-wl5fl2jb2', slug: 'the-times-view-on-tory-confidence-in-boris-johnson-pyrrhic-victory', label: 'LEADING ARTICLE', @@ -329,6 +346,8 @@ export default { { url: 'https://www.thetimes.co.uk/article/boris-johnson-allies-took-time-saving-big-dog-leadership-contest-rn5dzbw8h', + categoryPath: + 'l1/l2/article/boris-johnson-allies-took-time-saving-big-dog-leadership-contest-rn5dzbw8h', slug: 'boris-johnson-allies-took-time-saving-big-dog-leadership-contest', label: 'Politics', diff --git a/packages/ts-components/src/types/externs.d.ts b/packages/ts-components/src/types/externs.d.ts index 97afda401d6..0cab23bd504 100644 --- a/packages/ts-components/src/types/externs.d.ts +++ b/packages/ts-components/src/types/externs.d.ts @@ -24,6 +24,7 @@ declare module '@times-components/ts-slices' { export type SliceArticle = { id?: string; url?: string; + categoryPath?: string; label?: string; byline?: string; headline: string;