@newskit-render/core 2.21.2-alpha.0 → 2.22.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [2.21.2](https://github.com/newscorp-ghfb/ncu-newskit-render/compare/@newskit-render/core@2.21.2-alpha.0...@newskit-render/core@2.21.2) (2022-11-21)
7
+
8
+ **Note:** Version bump only for package @newskit-render/core
9
+
10
+
11
+
12
+
13
+
6
14
  ## [2.21.1](https://github.com/newscorp-ghfb/ncu-newskit-render/compare/@newskit-render/core@2.21.1-alpha.0...@newskit-render/core@2.21.1) (2022-11-17)
7
15
 
8
16
  **Note:** Version bump only for package @newskit-render/core
@@ -141,7 +141,7 @@ describe('Article', () => {
141
141
  req: { headers: { cookie: 'some-cookie', host: 'hostname' } },
142
142
  res: { setHeader: setHeaderMock },
143
143
  })
144
- expect(response).toEqual({
144
+ expect(response).toMatchObject({
145
145
  props: {
146
146
  ...props,
147
147
  showAds: true,
@@ -995,9 +995,6 @@ exports[`Recommendation render related article page when data is null page 1`] =
995
995
  <div
996
996
  class="css-1ji12ea"
997
997
  >
998
- <div
999
- class="css-9z2crs"
1000
- />
1001
998
  <div
1002
999
  class="css-6gys8z"
1003
1000
  >
@@ -1142,9 +1139,6 @@ exports[`Recommendation render related article page when data is null page 1`] =
1142
1139
  </div>
1143
1140
  </div>
1144
1141
  </div>
1145
- <div
1146
- class="css-14pl72w"
1147
- />
1148
1142
  <div
1149
1143
  class="css-75g92e"
1150
1144
  >
@@ -260,10 +260,6 @@ exports[`Recommendation render related article page when data is null page 1`] =
260
260
  </div>
261
261
  </div>
262
262
  </div>
263
- <div
264
- class="css-1ubx3ge"
265
- data-testid="Articles-Grid"
266
- />
267
263
  </div>
268
264
  </div>
269
265
  </div>
@@ -69,7 +69,7 @@ describe('Article', () => {
69
69
  req: { headers: { cookie: 'some-cookie' } },
70
70
  res: { setHeader: setHeaderMock },
71
71
  })
72
- expect(response).toEqual({
72
+ expect(response).toMatchObject({
73
73
  props: {
74
74
  ...props,
75
75
  showAds: true,
@@ -10,15 +10,10 @@ import {
10
10
  Visible,
11
11
  TitleBar,
12
12
  } from 'newskit'
13
- import { AricleGrid } from '@newskit-render/standalone-components'
13
+ import { RecommendedArticleList } from '@newskit-render/standalone-components'
14
14
  import ViewMoreButton from '../common/ViewMoreButton'
15
15
 
16
- const Highlights: React.FC<{
17
- highlightsArticles: {
18
- title: string
19
- href: string
20
- }[]
21
- }> = ({ highlightsArticles }) => (
16
+ const Highlights: React.FC = () => (
22
17
  <Block data-testid="Highlights" spaceStack="space060">
23
18
  <Block spaceStack="space060">
24
19
  <Visible xs lg xl>
@@ -59,7 +54,7 @@ const Highlights: React.FC<{
59
54
 
60
55
  <Block spaceStack="space040">
61
56
  <Grid xsMargin="space000">
62
- <AricleGrid articles={highlightsArticles} size="small" />
57
+ <RecommendedArticleList templateId="list-1" />
63
58
  <Cell xs={12}>
64
59
  <Visible xs lg xl>
65
60
  <Divider />
@@ -1,16 +1,10 @@
1
1
  import React from 'react'
2
2
  import { Block, TitleBar, Stack, StackChild, Divider, Visible } from 'newskit'
3
3
  import { useRouter } from 'next/router'
4
- import { AricleGrid } from '@newskit-render/standalone-components'
4
+ import { RecommendedArticleList } from '@newskit-render/standalone-components'
5
5
  import ViewMoreButton from '../common/ViewMoreButton'
6
6
 
7
- const RelatedArticles: React.FC<{
8
- relatedArticles: {
9
- title: string
10
- text?: string
11
- href: string
12
- }[]
13
- }> = ({ relatedArticles }) => {
7
+ const RelatedArticles: React.FC = () => {
14
8
  const { asPath } = useRouter()
15
9
  const relatedArticlesPath = `${asPath.substring(
16
10
  0,
@@ -39,11 +33,7 @@ const RelatedArticles: React.FC<{
39
33
  Related
40
34
  </TitleBar>
41
35
  </Block>
42
- <AricleGrid
43
- articles={relatedArticles}
44
- size="large"
45
- columnCount={{ xs: '1', sm: '2', lg: '4' }}
46
- />
36
+ <RecommendedArticleList templateId="list-2" />
47
37
  <Visible xs lg>
48
38
  <Divider />
49
39
  <Stack>
@@ -1086,7 +1086,7 @@ exports[`Article should render tile and sub title 1`] = `
1086
1086
  <img
1087
1087
  alt="Card Media"
1088
1088
  class="css-n57idg"
1089
- src="https://plchldr.co/i/50x50"
1089
+ src="https://plchldr.co/i/70x50"
1090
1090
  />
1091
1091
  </picture>
1092
1092
  </div>
@@ -1106,7 +1106,7 @@ exports[`Article should render tile and sub title 1`] = `
1106
1106
  <h4
1107
1107
  class="nk-headline-heading css-l6hs79"
1108
1108
  >
1109
- Test Box
1109
+ Prince Harry
1110
1110
  </h4>
1111
1111
  </section>
1112
1112
  </a>
@@ -1129,7 +1129,7 @@ exports[`Article should render tile and sub title 1`] = `
1129
1129
  <img
1130
1130
  alt="Card Media"
1131
1131
  class="css-n57idg"
1132
- src="https://plchldr.co/i/50x50"
1132
+ src="https://plchldr.co/i/70x50"
1133
1133
  />
1134
1134
  </picture>
1135
1135
  </div>
@@ -1149,7 +1149,7 @@ exports[`Article should render tile and sub title 1`] = `
1149
1149
  <h4
1150
1150
  class="nk-headline-heading css-l6hs79"
1151
1151
  >
1152
- Prince Harry
1152
+ Meghan Markle
1153
1153
  </h4>
1154
1154
  </section>
1155
1155
  </a>
@@ -1,5 +1,9 @@
1
+ import React from 'react'
2
+ import {
3
+ ArticleRecommendationsProviderContext,
4
+ DpaTemplate,
5
+ } from '@newskit-render/standalone-components'
1
6
  import { within } from '@testing-library/react'
2
-
3
7
  import Article, { ArticleProps } from '..'
4
8
  import { Slug, URL, Image, Video } from '../../../helpers/global-types'
5
9
  import { renderWithTheme } from '../../../helpers/test-utils'
@@ -89,6 +93,33 @@ const articleData: ArticleProps = {
89
93
  gscId: '4320982',
90
94
  }
91
95
 
96
+ const dpaTemplatesMock: DpaTemplate = [
97
+ {
98
+ templateId: 'list-1',
99
+ columnCount: '1',
100
+ size: 'small',
101
+ recommendedArticles: articleData.relatedArticles,
102
+ adlibraryMPU: [],
103
+ },
104
+ {
105
+ templateId: 'list-2',
106
+ columnCount: { xs: '1', sm: '2', lg: '4' },
107
+ size: 'large',
108
+ recommendedArticles: articleData.relatedArticles,
109
+ adlibraryMPU: [],
110
+ },
111
+ ]
112
+
113
+ const ArticleWrapper = (props) => (
114
+ <ArticleRecommendationsProviderContext.Provider
115
+ value={{
116
+ dpaTemplates: dpaTemplatesMock,
117
+ }}
118
+ >
119
+ <Article {...props} />
120
+ </ArticleRecommendationsProviderContext.Provider>
121
+ )
122
+
92
123
  jest.mock('@newskit-render/my-account', () => {
93
124
  return {
94
125
  PastDueBannerExternal: 'PastDueBannerExternal',
@@ -110,7 +141,10 @@ describe('Article', () => {
110
141
  HTMLImageElement.prototype.loading = 'lazy'
111
142
  })
112
143
  test('should render tile and sub title', () => {
113
- const { getByTestId, asFragment } = renderWithTheme(Article, articleData)
144
+ const { getByTestId, asFragment } = renderWithTheme(
145
+ ArticleWrapper,
146
+ articleData
147
+ )
114
148
  const headLine = within(getByTestId('HeadLine'))
115
149
  const kicker = within(getByTestId('Kicker'))
116
150
  const title = headLine.getByText(
@@ -123,7 +157,7 @@ describe('Article', () => {
123
157
  })
124
158
 
125
159
  test('should render byline', () => {
126
- const { getByTestId } = renderWithTheme(Article, articleData)
160
+ const { getByTestId } = renderWithTheme(ArticleWrapper, articleData)
127
161
  const byline = within(getByTestId('MetaBox'))
128
162
  const authorName = byline.getByText('John Smith')
129
163
  const authorTitle = byline.getByText('John Smith')
@@ -133,14 +167,14 @@ describe('Article', () => {
133
167
 
134
168
  test('should render published time', () => {
135
169
  articleData.updatedDateTime = undefined
136
- const { getByTestId } = renderWithTheme(Article, articleData)
170
+ const { getByTestId } = renderWithTheme(ArticleWrapper, articleData)
137
171
  const metaBox = within(getByTestId('MetaBox'))
138
172
  const date = metaBox.getByText('Thu February 14 2019, 12:00am')
139
173
  expect(date).toBeInTheDocument()
140
174
  })
141
175
 
142
176
  test('should render related topics', () => {
143
- const { getByTestId } = renderWithTheme(Article, articleData)
177
+ const { getByTestId } = renderWithTheme(ArticleWrapper, articleData)
144
178
  const topics = within(getByTestId('RelatedTopics')).getAllByTestId('tag')
145
179
  expect(topics[0].getAttribute('href')).toBe(null)
146
180
  expect(within(topics[0]).getByText('Some topic one')).toBeInTheDocument()
@@ -152,12 +186,12 @@ describe('Article', () => {
152
186
 
153
187
  test('should not render related topics', () => {
154
188
  articleData.topics = undefined
155
- const { getByTestId } = renderWithTheme(Article, articleData)
189
+ const { getByTestId } = renderWithTheme(ArticleWrapper, articleData)
156
190
  expect(() => getByTestId('topics')).toThrow()
157
191
  })
158
192
 
159
193
  test('should render highlights panel', () => {
160
- const { getByTestId } = renderWithTheme(Article, articleData)
194
+ const { getByTestId } = renderWithTheme(ArticleWrapper, articleData)
161
195
  const title = within(getByTestId('Highlights')).getAllByText(
162
196
  'Highlights'
163
197
  )[0]
@@ -168,14 +202,8 @@ describe('Article', () => {
168
202
  expect(card).toBeInTheDocument()
169
203
  })
170
204
 
171
- test('should not render highlights panel', () => {
172
- articleData.highlights = undefined
173
- const { getByTestId } = renderWithTheme(Article, articleData)
174
- expect(() => getByTestId('Highlights')).toThrow()
175
- })
176
-
177
205
  test('should render related articles panel', () => {
178
- const { getByTestId } = renderWithTheme(Article, articleData)
206
+ const { getByTestId } = renderWithTheme(ArticleWrapper, articleData)
179
207
  const title = within(getByTestId('RelatedArticles')).getByText('Related')
180
208
  const card = within(getByTestId('RelatedArticles')).getAllByTestId(
181
209
  'article-recommendation-large'
@@ -185,14 +213,8 @@ describe('Article', () => {
185
213
  expect(card).toBeInTheDocument()
186
214
  })
187
215
 
188
- test('should not render related articles pannel', () => {
189
- articleData.relatedArticles = undefined
190
- const { getByTestId } = renderWithTheme(Article, articleData)
191
- expect(() => getByTestId('RelatedArticles')).toThrow()
192
- })
193
-
194
216
  test('should render image', () => {
195
- const { getByAltText } = renderWithTheme(Article, articleData)
217
+ const { getByAltText } = renderWithTheme(ArticleWrapper, articleData)
196
218
  const img = getByAltText('testIMG')
197
219
  const articleImage = articleData?.media as Image
198
220
  expect(img.getAttribute('src')).toBe(articleImage.crops[0].url)
@@ -200,12 +222,12 @@ describe('Article', () => {
200
222
 
201
223
  test('should not render image', () => {
202
224
  articleData.media = undefined
203
- const { getByAltText } = renderWithTheme(Article, articleData)
225
+ const { getByAltText } = renderWithTheme(ArticleWrapper, articleData)
204
226
  expect(() => getByAltText('testIMG')).toThrow()
205
227
  })
206
228
 
207
229
  test('should render paragraphs', () => {
208
- const { getByTestId } = renderWithTheme(Article, articleData)
230
+ const { getByTestId } = renderWithTheme(ArticleWrapper, articleData)
209
231
  const paragraphs = getByTestId('ArticleContent')
210
232
  expect(within(paragraphs).getByText('paragraph one')).toBeInTheDocument()
211
233
  expect(within(paragraphs).getByText('paragraph two')).toBeInTheDocument()
@@ -214,7 +236,7 @@ describe('Article', () => {
214
236
 
215
237
  test('should not render paragraphs', () => {
216
238
  articleData.summary = undefined
217
- const { getByTestId } = renderWithTheme(Article, articleData)
239
+ const { getByTestId } = renderWithTheme(ArticleWrapper, articleData)
218
240
  expect(() =>
219
241
  within(getByTestId('ArticleContent')).getAllByTestId('ArticleParagraph')
220
242
  ).toThrow()
@@ -238,7 +260,7 @@ describe('Article', () => {
238
260
  },
239
261
  },
240
262
  }
241
- const { getByTestId } = renderWithTheme(Article, articleWithVideo)
263
+ const { getByTestId } = renderWithTheme(ArticleWrapper, articleWithVideo)
242
264
  const video = getByTestId('bc-video-player')
243
265
  const articleVideo = articleWithVideo?.media as Video
244
266
  expect(video.getAttribute('data-account')).toBe(articleVideo.accountId)
@@ -247,7 +269,7 @@ describe('Article', () => {
247
269
 
248
270
  test('should not render video', () => {
249
271
  articleData.media = undefined
250
- const { getByTestId } = renderWithTheme(Article, articleData)
272
+ const { getByTestId } = renderWithTheme(ArticleWrapper, articleData)
251
273
  expect(() => getByTestId('bc-video-player')).toThrow()
252
274
  })
253
275
  })
@@ -15,6 +15,7 @@ import {
15
15
  } from 'newskit'
16
16
  import { SEOComponent } from '@newskit-render/shared-components'
17
17
  import { UserData } from '@newskit-render/my-account'
18
+ import { Article } from '@newskit-render/standalone-components'
18
19
  import MetaBoxComponent from './MetaBox'
19
20
  import Ad from '../ad'
20
21
  import Highlights from './Highlights'
@@ -63,6 +64,7 @@ export type UniversalArticle = {
63
64
  }
64
65
 
65
66
  export type ArticleProps = {
67
+ relatedArticles?: Article[]
66
68
  id: string
67
69
  url?: URL
68
70
  label?: string
@@ -79,19 +81,6 @@ export type ArticleProps = {
79
81
  publishedDateTime?: string
80
82
  updatedDateTime?: string
81
83
  summary?: ParagraphBlock
82
- highlights:
83
- | {
84
- title: string
85
- href: string
86
- }[]
87
- | undefined
88
- relatedArticles:
89
- | {
90
- title: string
91
- text?: string
92
- href: string
93
- }[]
94
- | undefined
95
84
  articleURL: string
96
85
  twitterUsername?: string
97
86
  siteHost: string
@@ -112,8 +101,6 @@ const ArticlePage: React.FC<ArticleProps> = ({
112
101
  media,
113
102
  bylines,
114
103
  topics,
115
- highlights,
116
- relatedArticles,
117
104
  articleURL,
118
105
  twitterUsername,
119
106
  siteHost,
@@ -325,12 +312,10 @@ const ArticlePage: React.FC<ArticleProps> = ({
325
312
  </Cell>
326
313
  <Cell xs={12} lg={3} lgOffset={1}>
327
314
  <Ad id="advert-article-sidebar" maxWidth="300px" />
328
- {highlights && <Highlights highlightsArticles={highlights} />}
315
+ <Highlights />
329
316
  </Cell>
330
317
  <Cell xs={12}>
331
- {relatedArticles && (
332
- <RelatedArticles relatedArticles={relatedArticles} />
333
- )}
318
+ <RelatedArticles />
334
319
  </Cell>
335
320
  </Layout>
336
321
  </>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newskit-render/core",
3
- "version": "2.21.2-alpha.0",
3
+ "version": "2.22.0-alpha.0",
4
4
  "description": "Newskit Render - Core package",
5
5
  "author": "",
6
6
  "license": "UNLICENSED",
@@ -38,14 +38,14 @@
38
38
  "@emotion-icons/material-outlined": "3.14.0",
39
39
  "@emotion/react": "11.10.4",
40
40
  "@emotion/styled": "11.10.4",
41
- "@newskit-render/api": "^1.2.2-alpha.0",
41
+ "@newskit-render/api": "^1.3.0-alpha.0",
42
42
  "@newskit-render/auth": "^1.1.1",
43
- "@newskit-render/checkout": "^1.6.3-alpha.0",
43
+ "@newskit-render/checkout": "^1.6.4-alpha.0",
44
44
  "@newskit-render/feature-flags": "^1.2.0",
45
- "@newskit-render/feed": "^1.2.1-alpha.0",
46
- "@newskit-render/my-account": "^3.18.1-alpha.0",
45
+ "@newskit-render/feed": "^1.2.2-alpha.0",
46
+ "@newskit-render/my-account": "^3.18.2-alpha.0",
47
47
  "@newskit-render/shared-components": "^1.18.0",
48
- "@newskit-render/standalone-components": "^1.10.3-alpha.0",
48
+ "@newskit-render/standalone-components": "^1.11.0-alpha.0",
49
49
  "@newskit-render/validation": "^1.3.1",
50
50
  "cross-fetch": "3.1.5",
51
51
  "graphql": "15.6.0",
@@ -5,9 +5,10 @@ import {
5
5
  createApolloClient,
6
6
  ClientTypes,
7
7
  getAcsCookie,
8
+ Config,
8
9
  } from '@newskit-render/api'
9
10
  import { UserData } from '@newskit-render/my-account'
10
- import { Article } from '@newskit-render/standalone-components'
11
+ import { ArticleRecommendationsProvider } from '@newskit-render/standalone-components'
11
12
  import { getHost } from '@newskit-render/shared-components'
12
13
  import { initAndGetFeatureFlag } from '@newskit-render/feature-flags' // create-render-app effected
13
14
  import { GET_UNIVERSAL_ARTICLE } from '../../../queries'
@@ -18,9 +19,10 @@ import { addCacheHeaders } from '../../../helpers/addCacheHeaders'
18
19
  import {
19
20
  twitterUsername as configTwitterUsername,
20
21
  gscId as configGscId,
22
+ newskitApiEnvUrl,
23
+ newskitApiXApiKey,
21
24
  optimizelysdkKey, // create-render-app effected
22
25
  } from '../../../config'
23
- import { fetcher } from '../../../helpers/getRecommendations'
24
26
 
25
27
  export type ArticleSlug = {
26
28
  universalArticle: UniversalArticle
@@ -30,6 +32,7 @@ export type ArticleSlug = {
30
32
  gscId?: string
31
33
  user?: UserData
32
34
  articleId: string
35
+ config: Config
33
36
  }
34
37
 
35
38
  const Article: React.FC<ArticleSlug> = ({
@@ -40,35 +43,19 @@ const Article: React.FC<ArticleSlug> = ({
40
43
  gscId,
41
44
  user,
42
45
  articleId,
43
- }) => {
44
- let userId
45
- if (typeof window !== 'undefined') {
46
- userId = window?.utag?.data['cp.utag_main_v_id']
47
- }
48
- const highlitedArticles = []
49
- const relatedArticles = []
50
- const { data: recommendations } = useSWR<Article[]>(
51
- `/api/recommendations/${articleId}/${userId}`,
52
- fetcher
53
- )
54
-
55
- if (Array.isArray(recommendations)) {
56
- highlitedArticles.push(...recommendations.slice(0, 4))
57
- relatedArticles.push(...recommendations.slice(4, 12))
58
- }
59
- return (
46
+ config,
47
+ }) => (
48
+ <ArticleRecommendationsProvider articleId={articleId} config={config}>
60
49
  <ArticlePage
61
50
  articleURL={articleURL}
62
51
  {...universalArticle}
63
52
  siteHost={siteHost}
64
53
  gscId={gscId}
65
54
  twitterUsername={twitterUsername}
66
- highlights={highlitedArticles}
67
- relatedArticles={relatedArticles}
68
55
  user={user}
69
56
  />
70
- )
71
- }
57
+ </ArticleRecommendationsProvider>
58
+ )
72
59
 
73
60
  export async function getServerSideProps(context) {
74
61
  const apolloClient = await createApolloClient(ClientTypes.nkapi)
@@ -104,6 +91,10 @@ export async function getServerSideProps(context) {
104
91
  showAds: true,
105
92
  user,
106
93
  articleId,
94
+ config: {
95
+ newskitApiEnvUrl,
96
+ newskitApiXApiKey,
97
+ },
107
98
  featureFlags, // create-render-app effected
108
99
  },
109
100
  }
@@ -1,72 +1,63 @@
1
1
  import React from 'react'
2
2
  import newrelic from 'newrelic'
3
- import useSWR from 'swr'
4
- import { getAcsCookie, ClientTypes } from '@newskit-render/api'
5
- import { Article } from '@newskit-render/standalone-components'
3
+ import { getAcsCookie, ClientTypes, Config } from '@newskit-render/api'
4
+ import {
5
+ RecommendedArticleList,
6
+ ArticleRecommendationsProvider,
7
+ } from '@newskit-render/standalone-components'
6
8
  import { getHost } from '@newskit-render/shared-components'
7
9
  import { Block, Cell, TitleBar } from 'newskit'
8
10
  import { UserData } from '@newskit-render/my-account'
9
11
  import { initAndGetFeatureFlag } from '@newskit-render/feature-flags' // create-render-app effected
10
- import { optimizelysdkKey } from '../../../config' // create-render-app effected
11
12
  import { fetchUser } from '../../../helpers/getUser'
12
13
  import { getAccountQueryUrl } from '../../../constants'
13
14
  import { addCacheHeaders } from '../../../helpers/addCacheHeaders'
14
15
  import Layout from '../../../components/layout'
15
- import { BasicRow } from '../../../components/section/layouts'
16
- import { fetcher } from '../../../helpers/getRecommendations'
16
+ import {
17
+ newskitApiEnvUrl,
18
+ newskitApiXApiKey,
19
+ optimizelysdkKey, // create-render-app effected
20
+ } from '../../../config'
17
21
 
18
22
  export type RelatedArticles = {
19
23
  user?: UserData
20
24
  articleId
25
+ config: Config
21
26
  }
22
27
 
23
28
  const RelatedArticlesPage: React.FC<RelatedArticles> = ({
24
29
  user,
25
30
  articleId,
31
+ config,
26
32
  }) => {
27
- let userId: string
28
- if (typeof window !== 'undefined') {
29
- userId = window?.utag?.data['cp.utag_main_v_id']
30
- }
31
-
32
- const recommendations = []
33
- const { data: recommendationData } = useSWR<Article[]>(
34
- `/api/recommendations/${articleId}/${userId}`,
35
- fetcher
36
- )
37
-
38
- if (Array.isArray(recommendationData)) {
39
- recommendations.push(...recommendationData.slice(0, 4))
40
- }
41
33
  return (
42
- <Layout dataTestId="SectionGrid" user={user}>
43
- <Cell xs={12} md={10} mdOffset={1} data-testid="SectionCell">
44
- <Block spaceStack="space080" />
45
- <Block spaceStack="space080">
46
- <TitleBar
47
- overrides={{
48
- spaceInset: {
49
- xs: 'spaceInsetSquish000',
50
- },
51
- heading: {
52
- typographyPreset: {
53
- xs: 'editorialHeadline050',
54
- md: 'editorialHeadline060',
55
- xl: 'editorialHeadline070',
34
+ <ArticleRecommendationsProvider articleId={articleId} config={config}>
35
+ <Layout dataTestId="SectionGrid" user={user}>
36
+ <Cell xs={12} md={10} mdOffset={1} data-testid="SectionCell">
37
+ <Block spaceStack="space080" />
38
+ <Block spaceStack="space080">
39
+ <TitleBar
40
+ overrides={{
41
+ spaceInset: {
42
+ xs: 'spaceInsetSquish000',
43
+ },
44
+ heading: {
45
+ typographyPreset: {
46
+ xs: 'editorialHeadline050',
47
+ md: 'editorialHeadline060',
48
+ xl: 'editorialHeadline070',
49
+ },
50
+ stylePreset: 'inkContrast',
56
51
  },
57
- stylePreset: 'inkContrast',
58
- },
59
- }}
60
- >
61
- Related Articles
62
- </TitleBar>
63
- </Block>
64
- <BasicRow
65
- colums={{ xs: '1fr', md: '1fr 1fr', lg: '1fr 1fr 1fr' }}
66
- articles={recommendations}
67
- />
68
- </Cell>
69
- </Layout>
52
+ }}
53
+ >
54
+ Related Articles
55
+ </TitleBar>
56
+ </Block>
57
+ <RecommendedArticleList templateId="list-1" />
58
+ </Cell>
59
+ </Layout>
60
+ </ArticleRecommendationsProvider>
70
61
  )
71
62
  }
72
63
 
@@ -94,6 +85,10 @@ export async function getServerSideProps(context) {
94
85
  showAds: true,
95
86
  user,
96
87
  articleId,
88
+ config: {
89
+ newskitApiEnvUrl,
90
+ newskitApiXApiKey,
91
+ },
97
92
  featureFlags, // create-render-app effected
98
93
  },
99
94
  }
@@ -1,21 +0,0 @@
1
- import { NextApiRequest, NextApiResponse } from 'next'
2
- import { Publisher } from '@newskit-render/api'
3
- import { getRecommendations } from '../../../helpers/getRecommendations'
4
-
5
- const handler = async (req: NextApiRequest, res: NextApiResponse) => {
6
- try {
7
- const [articleId, userId] = req.query.slug as string[]
8
- const result = await getRecommendations({
9
- articleId,
10
- publisher: Publisher.SUN_UK,
11
- userId,
12
- })
13
- res.setHeader('Content-Type', 'application/json')
14
- res.end(JSON.stringify(result))
15
- } catch (error) {
16
- res.json(error)
17
- res.status(405).end()
18
- }
19
- }
20
-
21
- export default handler