Skip to content

Commit 7984955

Browse files
committed
add island for fetching onward content json to link up with the hosted onward component
1 parent d8f8cd0 commit 7984955

3 files changed

Lines changed: 61 additions & 50 deletions

File tree

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import { useApi } from '../lib/useApi';
2+
import type { Branding } from '../types/branding';
3+
import type { TrailType } from '../types/trails';
4+
import { HostedContentOnwards } from './HostedContentOnwards';
5+
6+
type Props = {
7+
url: string;
8+
branding?: Branding;
9+
};
10+
11+
type OnwardsResponse = {
12+
result: {
13+
owner: string;
14+
trails: Array<TrailType>;
15+
// trails: Array<{
16+
// /** URL of the article, used for the anchor tag */
17+
// url: string;
18+
// /** Headline of the article represented by trail */
19+
// headline: string;
20+
// /** Image thumbnail details for the article */
21+
// image: {
22+
// /** Trail image URL */
23+
// src: string;
24+
// /** Alt text for the trail image */
25+
// alt: string;
26+
// };
27+
// format: FEFormat;
28+
// }>;
29+
};
30+
};
31+
32+
export const FetchHostedOnwards = ({ branding, url }: Props) => {
33+
const { data } = useApi<OnwardsResponse>(url);
34+
35+
const { result: { trails = [] } = {} } = data ?? {};
36+
37+
if (!trails.length) {
38+
return null;
39+
}
40+
41+
return (
42+
<HostedContentOnwards
43+
trails={trails}
44+
brandName={branding?.sponsorName ?? ''}
45+
accentColor={branding?.hostedCampaignColour}
46+
/>
47+
);
48+
};

dotcom-rendering/src/layouts/HostedArticleLayout.tsx

Lines changed: 9 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import { ArticleContainer } from '../components/ArticleContainer';
1010
import { ArticleHeadline } from '../components/ArticleHeadline';
1111
import { CallToActionAtom } from '../components/CallToActionAtom';
1212
import { Caption } from '../components/Caption';
13+
import { FetchHostedOnwards } from '../components/FetchHostedOnwards.island';
1314
import { HostedContentDisclaimer } from '../components/HostedContentDisclaimer';
1415
import { HostedContentHeader } from '../components/HostedContentHeader';
15-
import { HostedContentOnwards } from '../components/HostedContentOnwards';
1616
import { Island } from '../components/Island';
1717
import { MainMedia } from '../components/MainMedia';
1818
import { Section } from '../components/Section';
@@ -26,7 +26,6 @@ import { palette as themePalette } from '../palette';
2626
import type { Article } from '../types/article';
2727
import type { Block } from '../types/blocks';
2828
import type { RenderingTarget } from '../types/renderingTarget';
29-
import type { TrailType } from '../types/trails';
3029
import { Stuck } from './lib/stickiness';
3130

3231
interface Props {
@@ -168,42 +167,6 @@ const sideBorders = css`
168167
border-right: 1px solid ${themePalette('--article-border')};
169168
}
170169
`;
171-
// This is dummy data until we have the actual trails for hosted content onwards.
172-
export const trails: TrailType[] = [
173-
{
174-
url: 'https://www.theguardian.com/money/gallery/2026/mar/27/loft-style-apartments-for-sale-in-england-in-pictures',
175-
headline: 'Loft-style apartments for sale in England – in pictures',
176-
format: { design: 27, display: 1, theme: 6 },
177-
dataLinkName: 'media | group-0 | card-@1',
178-
image: {
179-
src: 'https://media.guim.co.uk/276ed08e0380a9a3045a779ea1ca8c93f7c1b51e/500_0_5000_4000/2000.jpg',
180-
altText:
181-
'Loft-style apartment interior in Clapton, east London with industrial design elements',
182-
},
183-
},
184-
{
185-
url: 'https://www.theguardian.com/books/2026/apr/01/under-water-by-tara-menon-review-love-loss-and-a-longing-for-the-ocean',
186-
headline:
187-
'Under Water by Tara Menon review – love, loss and a longing for the ocean',
188-
format: { design: 27, display: 1, theme: 6 },
189-
dataLinkName: 'media | group-0 | card-@2',
190-
image: {
191-
src: 'https://media.guim.co.uk/95d6b3df9e3471344dc19a32d94bb3d5ff6f5016/205_5_2978_2382/2000.jpg',
192-
altText: 'Tropical fish',
193-
},
194-
},
195-
{
196-
url: 'https://www.theguardian.com/money/gallery/2026/feb/27/homes-a-short-walk-from-the-sea-in-england-and-scotland-in-pictures',
197-
headline:
198-
'Homes a short walk from the sea in England and Scotland – in pictures',
199-
format: { design: 27, display: 1, theme: 6 },
200-
dataLinkName: 'media | group-0 | card-@3',
201-
image: {
202-
src: 'https://media.guim.co.uk/9879e5d3275b5dae8c8bfd8e1ac700332e2de8c4/237_0_3750_3000/2000.jpg',
203-
altText: 'Craster, Northumberland',
204-
},
205-
},
206-
];
207170

208171
export const HostedArticleLayout = (props: WebProps | AppProps) => {
209172
const {
@@ -364,11 +327,14 @@ export const HostedArticleLayout = (props: WebProps | AppProps) => {
364327
</div>
365328

366329
<div css={onwardContentStyles}>
367-
<HostedContentOnwards
368-
trails={trails}
369-
brandName="TrendAI"
370-
accentColor={branding?.hostedCampaignColour}
371-
/>
330+
<Island priority="feature" defer={{ until: 'idle' }}>
331+
<FetchHostedOnwards
332+
url={
333+
'http://localhost:9000/advertiser-content/we-are-still-in/faces-of-we-are-still-in/onward.json'
334+
}
335+
branding={branding}
336+
/>
337+
</Island>
372338
</div>
373339

374340
{cta && (

dotcom-rendering/src/layouts/HostedVideoLayout.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import { ArticleContainer } from '../components/ArticleContainer';
1111
import { ArticleHeadline } from '../components/ArticleHeadline';
1212
import { CallToActionAtom } from '../components/CallToActionAtom';
1313
import { Caption } from '../components/Caption';
14+
import { FetchHostedOnwards } from '../components/FetchHostedOnwards.island';
1415
import { HostedContentDisclaimer } from '../components/HostedContentDisclaimer';
1516
import { HostedContentHeader } from '../components/HostedContentHeader';
16-
import { HostedContentOnwards } from '../components/HostedContentOnwards';
1717
import { Island } from '../components/Island';
1818
import { MainMedia } from '../components/MainMedia';
1919
import { Section } from '../components/Section';
@@ -28,7 +28,6 @@ import type { Article } from '../types/article';
2828
import type { Block } from '../types/blocks';
2929
import type { FEElement } from '../types/content';
3030
import type { RenderingTarget } from '../types/renderingTarget';
31-
import { trails } from './HostedArticleLayout';
3231
import { Stuck } from './lib/stickiness';
3332

3433
interface Props {
@@ -323,11 +322,9 @@ export const HostedVideoLayout = (props: WebProps | AppProps) => {
323322
</div>
324323

325324
<div css={onwardContentStyles}>
326-
<HostedContentOnwards
327-
trails={trails} //Temporary trails dummy data which is exported from HostedArticleLayout
328-
brandName="TrendAI"
329-
accentColor={branding?.hostedCampaignColour}
330-
/>
325+
<Island priority="feature" defer={{ until: 'idle' }}>
326+
<FetchHostedOnwards branding={branding} />
327+
</Island>
331328
</div>
332329

333330
{cta && (

0 commit comments

Comments
 (0)