@newskit-render/core 1.4.5 → 1.9.3
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/.eslintignore +1 -0
- package/CHANGELOG.md +159 -0
- package/__tests__/pages/[articleSlug].test.tsx +1 -3
- package/__tests__/pages/__snapshots__/home.test.tsx.snap +1 -1
- package/__tests__/pages/home.test.tsx +0 -5
- package/components/article/__tests__/__snapshots__/index.test.tsx.snap +1 -2
- package/components/article/__tests__/index.test.tsx +0 -1
- package/components/article/index.tsx +1 -1
- package/components/section/layouts/__tests__/__snapshots__/Lead.test.tsx.snap +1 -1
- package/infrastructure/terraform-newrelic/dashboards.tf +176 -0
- package/infrastructure/terraform-newrelic/lighthouse-script-prod.js +46 -0
- package/infrastructure/terraform-newrelic/lighthouse-script.js +46 -0
- package/infrastructure/terraform-newrelic/monitors.tf +12 -0
- package/package.json +10 -11
- package/pages/[section]/[articleId]/[articleSlug].tsx +10 -13
- package/pages/[section]/index.tsx +12 -9
- package/pages/checkout/account-creation/index.tsx +7 -0
- package/pages/checkout/payment-details/index.tsx +7 -0
- package/pages/index.tsx +11 -9
- package/queries/getUserSubscription.ts +0 -13
- package/tsconfig.json +1 -1
- package/components/seo/index.test.tsx +0 -106
- package/components/seo/index.tsx +0 -89
package/.eslintignore
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,165 @@
|
|
|
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
|
+
## [1.9.3](https://github.com/newscorp-ghfb/ncu-newskit-render/compare/@newskit-render/core@1.9.2...@newskit-render/core@1.9.3) (2022-01-05)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @newskit-render/core
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [1.9.2](https://github.com/newscorp-ghfb/ncu-newskit-render/compare/@newskit-render/core@1.9.1...@newskit-render/core@1.9.2) (2022-01-04)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @newskit-render/core
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## [1.9.1](https://github.com/newscorp-ghfb/ncu-newskit-render/compare/@newskit-render/core@1.9.0...@newskit-render/core@1.9.1) (2022-01-04)
|
|
23
|
+
|
|
24
|
+
**Note:** Version bump only for package @newskit-render/core
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
# [1.9.0](https://github.com/newscorp-ghfb/ncu-newskit-render/compare/@newskit-render/core@1.8.0...@newskit-render/core@1.9.0) (2022-01-04)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
### Features
|
|
34
|
+
|
|
35
|
+
* **PPDSR-518:** add basic page context ([#544](https://github.com/newscorp-ghfb/ncu-newskit-render/issues/544)) ([16d3cbd](https://github.com/newscorp-ghfb/ncu-newskit-render/commit/16d3cbd561aadd124c1856a3297b515c1b164935))
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
# [1.8.0](https://github.com/newscorp-ghfb/ncu-newskit-render/compare/@newskit-render/core@1.7.1...@newskit-render/core@1.8.0) (2021-12-21)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
### Features
|
|
45
|
+
|
|
46
|
+
* **PPDSR-559:** Replace go MAIN with newest version ([#536](https://github.com/newscorp-ghfb/ncu-newskit-render/issues/536)) ([ba9a571](https://github.com/newscorp-ghfb/ncu-newskit-render/commit/ba9a571f8c6ce27c93d6d7ad9e35df6f61d627eb))
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
## [1.7.1](https://github.com/newscorp-ghfb/ncu-newskit-render/compare/@newskit-render/core@1.7.0...@newskit-render/core@1.7.1) (2021-12-16)
|
|
53
|
+
|
|
54
|
+
**Note:** Version bump only for package @newskit-render/core
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
# [1.7.0](https://github.com/newscorp-ghfb/ncu-newskit-render/compare/@newskit-render/core@1.6.1...@newskit-render/core@1.7.0) (2021-12-16)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
### Features
|
|
64
|
+
|
|
65
|
+
* **PPDSR-590:** Commenting preferences page redesign ([#540](https://github.com/newscorp-ghfb/ncu-newskit-render/issues/540)) ([0ac17d0](https://github.com/newscorp-ghfb/ncu-newskit-render/commit/0ac17d0c1682a6a1497f8705017cefc0fc7c3bb1))
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
## [1.6.1](https://github.com/newscorp-ghfb/ncu-newskit-render/compare/@newskit-render/core@1.6.0...@newskit-render/core@1.6.1) (2021-12-16)
|
|
72
|
+
|
|
73
|
+
**Note:** Version bump only for package @newskit-render/core
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
# [1.6.0](https://github.com/newscorp-ghfb/ncu-newskit-render/compare/@newskit-render/core@1.5.7...@newskit-render/core@1.6.0) (2021-12-15)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
### Features
|
|
83
|
+
|
|
84
|
+
* **PPDSR-520:** Add SEO Component ([#539](https://github.com/newscorp-ghfb/ncu-newskit-render/issues/539)) ([f9a7103](https://github.com/newscorp-ghfb/ncu-newskit-render/commit/f9a71034e9e7224975d785fb47c68b907b4e5935))
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
## [1.5.7](https://github.com/newscorp-ghfb/ncu-newskit-render/compare/@newskit-render/core@1.5.6...@newskit-render/core@1.5.7) (2021-12-14)
|
|
91
|
+
|
|
92
|
+
**Note:** Version bump only for package @newskit-render/core
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
## [1.5.6](https://github.com/newscorp-ghfb/ncu-newskit-render/compare/@newskit-render/core@1.5.5...@newskit-render/core@1.5.6) (2021-12-13)
|
|
99
|
+
|
|
100
|
+
**Note:** Version bump only for package @newskit-render/core
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
## [1.5.5](https://github.com/newscorp-ghfb/ncu-newskit-render/compare/@newskit-render/core@1.5.4...@newskit-render/core@1.5.5) (2021-12-13)
|
|
107
|
+
|
|
108
|
+
**Note:** Version bump only for package @newskit-render/core
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
## [1.5.4](https://github.com/newscorp-ghfb/ncu-newskit-render/compare/@newskit-render/core@1.5.3...@newskit-render/core@1.5.4) (2021-12-10)
|
|
115
|
+
|
|
116
|
+
**Note:** Version bump only for package @newskit-render/core
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
## [1.5.3](https://github.com/newscorp-ghfb/ncu-newskit-render/compare/@newskit-render/core@1.5.2...@newskit-render/core@1.5.3) (2021-12-08)
|
|
123
|
+
|
|
124
|
+
**Note:** Version bump only for package @newskit-render/core
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
## [1.5.2](https://github.com/newscorp-ghfb/ncu-newskit-render/compare/@newskit-render/core@1.5.1...@newskit-render/core@1.5.2) (2021-12-03)
|
|
131
|
+
|
|
132
|
+
**Note:** Version bump only for package @newskit-render/core
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
## [1.5.1](https://github.com/newscorp-ghfb/ncu-newskit-render/compare/@newskit-render/core@1.5.0...@newskit-render/core@1.5.1) (2021-12-02)
|
|
139
|
+
|
|
140
|
+
**Note:** Version bump only for package @newskit-render/core
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
# [1.5.0](https://github.com/newscorp-ghfb/ncu-newskit-render/compare/@newskit-render/core@1.4.6...@newskit-render/core@1.5.0) (2021-12-02)
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
### Features
|
|
150
|
+
|
|
151
|
+
* **PPDSR-517:** Add Grid Component ([#528](https://github.com/newscorp-ghfb/ncu-newskit-render/issues/528)) ([0f8082d](https://github.com/newscorp-ghfb/ncu-newskit-render/commit/0f8082d1490750f408c0c5ec2c7bd6af3a1ace18))
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
## [1.4.6](https://github.com/newscorp-ghfb/ncu-newskit-render/compare/@newskit-render/core@1.4.5...@newskit-render/core@1.4.6) (2021-11-30)
|
|
158
|
+
|
|
159
|
+
**Note:** Version bump only for package @newskit-render/core
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
|
|
6
165
|
## [1.4.5](https://github.com/newscorp-ghfb/ncu-newskit-render/compare/@newskit-render/core@1.4.4...@newskit-render/core@1.4.5) (2021-11-30)
|
|
7
166
|
|
|
8
167
|
**Note:** Version bump only for package @newskit-render/core
|
|
@@ -93,14 +93,12 @@ jest.mock('@newskit-render/api', () => ({
|
|
|
93
93
|
}),
|
|
94
94
|
})
|
|
95
95
|
}),
|
|
96
|
-
sessionParser: jest.fn(),
|
|
97
96
|
getMainSession: jest.fn(),
|
|
98
97
|
}))
|
|
99
98
|
|
|
100
99
|
jest.mock('@newskit-render/my-account', () => {
|
|
101
100
|
return {
|
|
102
101
|
PastDueBannerExternal: 'PastDueBannerExternal',
|
|
103
|
-
sessionParser: jest.fn(),
|
|
104
102
|
getMainSession: jest.fn(),
|
|
105
103
|
}
|
|
106
104
|
})
|
|
@@ -140,7 +138,7 @@ describe('Article', () => {
|
|
|
140
138
|
req: { headers: { cookie: 'some-cookie' } },
|
|
141
139
|
res: { setHeader: setHeaderMock },
|
|
142
140
|
})
|
|
143
|
-
expect(response).toEqual({ props: { ...props
|
|
141
|
+
expect(response).toEqual({ props: { ...props } })
|
|
144
142
|
expect(setHeaderMock).toHaveBeenCalledWith(
|
|
145
143
|
'Cache-Control',
|
|
146
144
|
'public, s-maxage=10, stale-while-revalidate=59'
|
|
@@ -19,7 +19,6 @@ jest.mock('@newskit-render/api', () => ({
|
|
|
19
19
|
}),
|
|
20
20
|
})
|
|
21
21
|
}),
|
|
22
|
-
sessionParser: jest.fn(),
|
|
23
22
|
getMainSession: jest.fn(),
|
|
24
23
|
}))
|
|
25
24
|
|
|
@@ -37,7 +36,6 @@ jest.mock('cross-fetch', () =>
|
|
|
37
36
|
jest.mock('@newskit-render/my-account', () => {
|
|
38
37
|
return {
|
|
39
38
|
PastDueBannerExternal: 'PastDueBannerExternal',
|
|
40
|
-
sessionParser: jest.fn(),
|
|
41
39
|
}
|
|
42
40
|
})
|
|
43
41
|
|
|
@@ -63,9 +61,6 @@ describe('getServerSideProps', () => {
|
|
|
63
61
|
title: 'Test title',
|
|
64
62
|
},
|
|
65
63
|
},
|
|
66
|
-
user: {
|
|
67
|
-
vxInstances: null,
|
|
68
|
-
},
|
|
69
64
|
},
|
|
70
65
|
})
|
|
71
66
|
)
|
|
@@ -2503,9 +2503,8 @@ exports[`Article should render tile and sub title 1`] = `
|
|
|
2503
2503
|
position: relative;
|
|
2504
2504
|
width: 100%;
|
|
2505
2505
|
display: block;
|
|
2506
|
-
padding-top: 66%;
|
|
2507
|
-
height: 0;
|
|
2508
2506
|
width: 150px;
|
|
2507
|
+
height: 100px;
|
|
2509
2508
|
border-radius: 0;
|
|
2510
2509
|
background-color: #F4F4F4;
|
|
2511
2510
|
}
|
|
@@ -13,13 +13,13 @@ import {
|
|
|
13
13
|
TextBlock,
|
|
14
14
|
Divider,
|
|
15
15
|
} from 'newskit'
|
|
16
|
+
import { SEOComponent } from '@newskit-render/shared-components'
|
|
16
17
|
import MetaBoxComponent from './MetaBox'
|
|
17
18
|
import Ad from '../ad'
|
|
18
19
|
import Highlights from './Highlights'
|
|
19
20
|
import RelatedArticles from './RelatedArticles'
|
|
20
21
|
import RelatedTopics from './RelatedTopics'
|
|
21
22
|
import ShareBarComponent from './ShareBarComponent'
|
|
22
|
-
import SEOComponent from '../seo'
|
|
23
23
|
import {
|
|
24
24
|
URL,
|
|
25
25
|
Slug,
|
|
@@ -169,3 +169,179 @@ resource "newrelic_one_dashboard" "frontend_dashboard" {
|
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
|
+
|
|
173
|
+
resource "newrelic_one_dashboard" "lighthouse_dashboard" {
|
|
174
|
+
name = "${data.newrelic_entity.render_app.name} Lighthouse Dashboard"
|
|
175
|
+
|
|
176
|
+
page {
|
|
177
|
+
name = "${data.newrelic_entity.render_app.name} Lighthouse Metrics Dashboard"
|
|
178
|
+
|
|
179
|
+
widget_billboard {
|
|
180
|
+
title = "Lighthouse Metrics"
|
|
181
|
+
row = 1
|
|
182
|
+
column = 1
|
|
183
|
+
height = 3
|
|
184
|
+
width = 4
|
|
185
|
+
|
|
186
|
+
nrql_query {
|
|
187
|
+
query = "FROM SyntheticCheck SELECT average(custom.firstContentfulPaint) as 'FCP', average(custom.largestContentfulPaint) as 'LCP', average(custom.interactive) as 'TTI', average(custom.totalBlockingTime) as 'TBT', average(custom.cumulativeLayoutShift) as 'CLS', average(custom.speedIndex) as 'Speed Index'"
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
widget_line {
|
|
192
|
+
title = "Lighthouse Metrics-trending"
|
|
193
|
+
row = 1
|
|
194
|
+
column = 5
|
|
195
|
+
height = 3
|
|
196
|
+
width = 8
|
|
197
|
+
|
|
198
|
+
nrql_query {
|
|
199
|
+
query = "FROM SyntheticCheck SELECT average(custom.firstContentfulPaint) as 'FCP', average(custom.largestContentfulPaint) as 'LCP', average(custom.interactive) as 'TTI', average(custom.totalBlockingTime) as 'TBT', average(custom.cumulativeLayoutShift) as 'CLS', average(custom.speedIndex) as 'Speed Index' TIMESERIES AUTO"
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
widget_bar {
|
|
204
|
+
title = "First Contentful Paint"
|
|
205
|
+
row = 4
|
|
206
|
+
column = 1
|
|
207
|
+
height = 3
|
|
208
|
+
width = 4
|
|
209
|
+
|
|
210
|
+
nrql_query {
|
|
211
|
+
query = "FROM SyntheticCheck SELECT average(custom.firstContentfulPaint) FACET custom.url"
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
widget_line {
|
|
216
|
+
title = "First Contentful Paint"
|
|
217
|
+
row = 4
|
|
218
|
+
column = 5
|
|
219
|
+
height = 3
|
|
220
|
+
width = 8
|
|
221
|
+
|
|
222
|
+
nrql_query {
|
|
223
|
+
query = "FROM SyntheticCheck SELECT average(custom.firstContentfulPaint) FACET custom.url TIMESERIES AUTO"
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
widget_bar {
|
|
228
|
+
title = "Largest Contentful Paint"
|
|
229
|
+
row = 7
|
|
230
|
+
column = 1
|
|
231
|
+
height = 3
|
|
232
|
+
width = 4
|
|
233
|
+
|
|
234
|
+
nrql_query {
|
|
235
|
+
query = "FROM SyntheticCheck SELECT average(custom.largestContentfulPaint) FACET custom.url"
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
widget_line {
|
|
240
|
+
title = "Largest Contentful Paint"
|
|
241
|
+
row = 7
|
|
242
|
+
column = 5
|
|
243
|
+
height = 3
|
|
244
|
+
width = 8
|
|
245
|
+
|
|
246
|
+
nrql_query {
|
|
247
|
+
query = "FROM SyntheticCheck SELECT average(custom.largestContentfulPaint) FACET custom.url TIMESERIES AUTO"
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
widget_bar {
|
|
252
|
+
title = "TTI"
|
|
253
|
+
row = 10
|
|
254
|
+
column = 1
|
|
255
|
+
height = 3
|
|
256
|
+
width = 4
|
|
257
|
+
|
|
258
|
+
nrql_query {
|
|
259
|
+
query = "FROM SyntheticCheck SELECT average(custom.interactive) as 'TTI' FACET custom.url"
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
widget_line {
|
|
264
|
+
title = "TTI - trending"
|
|
265
|
+
row = 10
|
|
266
|
+
column = 5
|
|
267
|
+
height = 3
|
|
268
|
+
width = 8
|
|
269
|
+
|
|
270
|
+
nrql_query {
|
|
271
|
+
query = "FROM SyntheticCheck SELECT average(custom.interactive) FACET custom.url TIMESERIES AUTO"
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
widget_bar {
|
|
276
|
+
title = "Total Blocking Time (TBT)"
|
|
277
|
+
row = 13
|
|
278
|
+
column = 1
|
|
279
|
+
height = 3
|
|
280
|
+
width = 4
|
|
281
|
+
|
|
282
|
+
nrql_query {
|
|
283
|
+
query = "FROM SyntheticCheck SELECT average(custom.totalBlockingTime) FACET custom.url"
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
widget_line {
|
|
288
|
+
title = "Total Blocking Time (TBT) - trending"
|
|
289
|
+
row = 13
|
|
290
|
+
column = 5
|
|
291
|
+
height = 3
|
|
292
|
+
width = 8
|
|
293
|
+
|
|
294
|
+
nrql_query {
|
|
295
|
+
query = "FROM SyntheticCheck SELECT average(custom.totalBlockingTime) FACET custom.url TIMESERIES AUTO"
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
widget_bar {
|
|
300
|
+
title = "Cumulative Layout Shift (CLS)"
|
|
301
|
+
row = 16
|
|
302
|
+
column = 1
|
|
303
|
+
height = 3
|
|
304
|
+
width = 4
|
|
305
|
+
|
|
306
|
+
nrql_query {
|
|
307
|
+
query = "FROM SyntheticCheck SELECT average(custom.cumulativeLayoutShift) FACET custom.url"
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
widget_line {
|
|
312
|
+
title = "Cumulative Layout Shift (CLS)"
|
|
313
|
+
row = 16
|
|
314
|
+
column = 5
|
|
315
|
+
height = 3
|
|
316
|
+
width = 8
|
|
317
|
+
|
|
318
|
+
nrql_query {
|
|
319
|
+
query = "FROM SyntheticCheck SELECT average(custom.cumulativeLayoutShift) FACET custom.url TIMESERIES AUTO"
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
widget_bar {
|
|
324
|
+
title = "Speed Index"
|
|
325
|
+
row = 19
|
|
326
|
+
column = 1
|
|
327
|
+
height = 3
|
|
328
|
+
width = 4
|
|
329
|
+
|
|
330
|
+
nrql_query {
|
|
331
|
+
query = "FROM SyntheticCheck SELECT average(custom.speedIndex) FACET custom.url"
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
widget_line {
|
|
336
|
+
title = "Speed Index - trading"
|
|
337
|
+
row = 19
|
|
338
|
+
column = 5
|
|
339
|
+
height = 3
|
|
340
|
+
width = 8
|
|
341
|
+
|
|
342
|
+
nrql_query {
|
|
343
|
+
query = "FROM SyntheticCheck SELECT average(custom.speedIndex) FACET custom.url TIMESERIES AUTO"
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/** API SETUP - remove this section to run in New Relic Synthetics **/
|
|
2
|
+
// if ($http == null) { var $http = require('request'); }
|
|
3
|
+
/** API SETUP - remove this section to run in New Relic Synthetics **/
|
|
4
|
+
|
|
5
|
+
var settings = {
|
|
6
|
+
url: 'https://newskit-render.prod.ceng.newsuk.tech/',
|
|
7
|
+
category: 'performance',
|
|
8
|
+
strategy: 'desktop',
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
var options = {
|
|
12
|
+
method: 'GET',
|
|
13
|
+
url: 'https://www.googleapis.com/pagespeedonline/v5/runPagespeed',
|
|
14
|
+
headers: null,
|
|
15
|
+
qs: settings,
|
|
16
|
+
json: true,
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
$http(options, function (error, response, body) {
|
|
20
|
+
if (!error && response.statusCode == 200) {
|
|
21
|
+
if (response.statusCode == 200) {
|
|
22
|
+
var lighthouseMetrics =
|
|
23
|
+
body.lighthouseResult.audits.metrics.details.items[0]
|
|
24
|
+
$util.insights.set('url', settings.url)
|
|
25
|
+
$util.insights.set('deviceType', settings.strategy)
|
|
26
|
+
$util.insights.set(
|
|
27
|
+
'performanceScore',
|
|
28
|
+
body.lighthouseResult.categories.performance.score
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
for (var attributeName in lighthouseMetrics) {
|
|
32
|
+
if (lighthouseMetrics.hasOwnProperty(attributeName)) {
|
|
33
|
+
if (!attributeName.includes('Ts')) {
|
|
34
|
+
console.log(attributeName + ': ' + lighthouseMetrics[attributeName])
|
|
35
|
+
$util.insights.set(attributeName, lighthouseMetrics[attributeName])
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
} else {
|
|
40
|
+
console.log('Non-200 HTTP response: ' + response.statusCode)
|
|
41
|
+
}
|
|
42
|
+
} else {
|
|
43
|
+
console.log('rsp code: ' + response.statusCode)
|
|
44
|
+
console.log(error)
|
|
45
|
+
}
|
|
46
|
+
})
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/** API SETUP - remove this section to run in New Relic Synthetics **/
|
|
2
|
+
// if ($http == null) { var $http = require('request'); }
|
|
3
|
+
/** API SETUP - remove this section to run in New Relic Synthetics **/
|
|
4
|
+
|
|
5
|
+
var settings = {
|
|
6
|
+
url: 'https://newskit-render.ceng-dev.newsuk.tech/',
|
|
7
|
+
category: 'performance',
|
|
8
|
+
strategy: 'desktop',
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
var options = {
|
|
12
|
+
method: 'GET',
|
|
13
|
+
url: 'https://www.googleapis.com/pagespeedonline/v5/runPagespeed',
|
|
14
|
+
headers: null,
|
|
15
|
+
qs: settings,
|
|
16
|
+
json: true,
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
$http(options, function (error, response, body) {
|
|
20
|
+
if (!error && response.statusCode == 200) {
|
|
21
|
+
if (response.statusCode == 200) {
|
|
22
|
+
var lighthouseMetrics =
|
|
23
|
+
body.lighthouseResult.audits.metrics.details.items[0]
|
|
24
|
+
$util.insights.set('url', settings.url)
|
|
25
|
+
$util.insights.set('deviceType', settings.strategy)
|
|
26
|
+
$util.insights.set(
|
|
27
|
+
'performanceScore',
|
|
28
|
+
body.lighthouseResult.categories.performance.score
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
for (var attributeName in lighthouseMetrics) {
|
|
32
|
+
if (lighthouseMetrics.hasOwnProperty(attributeName)) {
|
|
33
|
+
if (!attributeName.includes('Ts')) {
|
|
34
|
+
console.log(attributeName + ': ' + lighthouseMetrics[attributeName])
|
|
35
|
+
$util.insights.set(attributeName, lighthouseMetrics[attributeName])
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
} else {
|
|
40
|
+
console.log('Non-200 HTTP response: ' + response.statusCode)
|
|
41
|
+
}
|
|
42
|
+
} else {
|
|
43
|
+
console.log('rsp code: ' + response.statusCode)
|
|
44
|
+
console.log(error)
|
|
45
|
+
}
|
|
46
|
+
})
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
resource "newrelic_synthetics_monitor" "lighthouse-monitor" {
|
|
2
|
+
name = "${data.newrelic_entity.render_app.name} Lighthouse Monitor"
|
|
3
|
+
type = "SCRIPT_API"
|
|
4
|
+
frequency = 30
|
|
5
|
+
status = "ENABLED"
|
|
6
|
+
locations = ["AWS_EU_WEST_2"]
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
resource "newrelic_synthetics_monitor_script" "lighthouse-script" {
|
|
10
|
+
monitor_id = newrelic_synthetics_monitor.lighthouse-monitor.id
|
|
11
|
+
text = "${var.environment}" == "prod" ? file("${path.module}/lighthouse-script-prod.js") : file("${path.module}/lighthouse-script.js")
|
|
12
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@newskit-render/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.3",
|
|
4
4
|
"description": "Newskit Render - Core package",
|
|
5
5
|
"author": "",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -28,23 +28,22 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@apollo/client": "^3.4.16",
|
|
31
|
-
"@newskit-render/api": "^0.
|
|
32
|
-
"@newskit-render/auth": "^0.22.
|
|
33
|
-
"@newskit-render/checkout": "^0.
|
|
34
|
-
"@newskit-render/my-account": "^0.
|
|
35
|
-
"@newskit-render/shared-components": "^0.
|
|
36
|
-
"@newskit-render/sitemap": "^0.25.
|
|
37
|
-
"@newskit-render/validation": "^0.
|
|
31
|
+
"@newskit-render/api": "^0.5.0",
|
|
32
|
+
"@newskit-render/auth": "^0.22.2",
|
|
33
|
+
"@newskit-render/checkout": "^0.9.0",
|
|
34
|
+
"@newskit-render/my-account": "^0.116.2",
|
|
35
|
+
"@newskit-render/shared-components": "^0.20.0",
|
|
36
|
+
"@newskit-render/sitemap": "^0.25.3",
|
|
37
|
+
"@newskit-render/validation": "^0.27.0",
|
|
38
38
|
"cross-fetch": "^3.1.4",
|
|
39
39
|
"graphql": "^15.6.0",
|
|
40
40
|
"newrelic": "^7.1.0",
|
|
41
|
-
"newskit": "4.
|
|
41
|
+
"newskit": "4.3.1",
|
|
42
42
|
"next": "^12.0.2",
|
|
43
43
|
"react": "^17.0.1",
|
|
44
44
|
"react-dom": "^17.0.2",
|
|
45
45
|
"react-helmet": "^6.1.0",
|
|
46
|
-
"react-hook-form": "7.8.4"
|
|
47
|
-
"striptags": "^3.1.1"
|
|
46
|
+
"react-hook-form": "7.8.4"
|
|
48
47
|
},
|
|
49
48
|
"devDependencies": {
|
|
50
49
|
"@apollo/react-testing": "^4.0.0",
|
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import newrelic from 'newrelic'
|
|
3
|
-
import {
|
|
4
|
-
createApolloClient,
|
|
5
|
-
sessionParser,
|
|
6
|
-
getMainSession,
|
|
7
|
-
ClientTypes,
|
|
8
|
-
} from '@newskit-render/api'
|
|
3
|
+
import { createApolloClient, ClientTypes } from '@newskit-render/api'
|
|
9
4
|
import { GET_UNIVERSAL_ARTICLE } from '../../../queries'
|
|
10
5
|
import ArticlePage, { UniversalArticle } from '../../../components/article'
|
|
11
6
|
import { highlights, relatedArticles } from '../../../helpers/mocks/articleMock'
|
|
12
7
|
import { UserData } from '../../../helpers/global-types'
|
|
13
|
-
import { fetchUser } from '../../../helpers/getUser'
|
|
14
|
-
import { ACCOUNT_QUERY_URL } from '../../../constants'
|
|
8
|
+
// import { fetchUser } from '../../../helpers/getUser'
|
|
9
|
+
// import { ACCOUNT_QUERY_URL } from '../../../constants'
|
|
15
10
|
import { addCacheHeaders } from '../../../helpers/addCacheHeaders'
|
|
16
11
|
|
|
17
12
|
export type ArticleSlug = {
|
|
@@ -46,8 +41,7 @@ const Article: React.FC<ArticleSlug> = ({
|
|
|
46
41
|
|
|
47
42
|
export async function getServerSideProps(context) {
|
|
48
43
|
const apolloClient = await createApolloClient(ClientTypes.nkapi)
|
|
49
|
-
const mainSession = getMainSession(context.req.headers.cookie)
|
|
50
|
-
const session = sessionParser(mainSession)
|
|
44
|
+
// const mainSession = getMainSession(context.req.headers.cookie)
|
|
51
45
|
|
|
52
46
|
const {
|
|
53
47
|
params: { articleId, section, articleSlug },
|
|
@@ -57,12 +51,15 @@ export async function getServerSideProps(context) {
|
|
|
57
51
|
`Article: /${section}/${articleId}/${articleSlug}`
|
|
58
52
|
)
|
|
59
53
|
|
|
60
|
-
const [
|
|
54
|
+
const [
|
|
55
|
+
{ data },
|
|
56
|
+
// user
|
|
57
|
+
] = await Promise.all([
|
|
61
58
|
apolloClient.query({
|
|
62
59
|
query: GET_UNIVERSAL_ARTICLE,
|
|
63
60
|
variables: { publisher: 'DEMO', id: articleId },
|
|
64
61
|
}),
|
|
65
|
-
await fetchUser(
|
|
62
|
+
// await fetchUser(mainSession, ACCOUNT_QUERY_URL),
|
|
66
63
|
])
|
|
67
64
|
|
|
68
65
|
addCacheHeaders(context.res)
|
|
@@ -73,7 +70,7 @@ export async function getServerSideProps(context) {
|
|
|
73
70
|
twitterUsername: process.env.TWITTER_USERNAME || '',
|
|
74
71
|
siteHost: process.env.SITE_HOST || '',
|
|
75
72
|
gscId: process.env.GSC_ID || '',
|
|
76
|
-
user,
|
|
73
|
+
// user,
|
|
77
74
|
},
|
|
78
75
|
}
|
|
79
76
|
}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import newrelic from 'newrelic'
|
|
2
2
|
import {
|
|
3
3
|
createApolloClient,
|
|
4
|
-
|
|
5
|
-
getMainSession,
|
|
4
|
+
// getMainSession,
|
|
6
5
|
ClientTypes,
|
|
7
6
|
} from '@newskit-render/api'
|
|
8
7
|
import { GET_PAGE } from '../../queries'
|
|
9
8
|
import SectionPage from '../../components/section'
|
|
10
|
-
import { fetchUser } from '../../helpers/getUser'
|
|
11
|
-
import { ACCOUNT_QUERY_URL } from '../../constants'
|
|
9
|
+
// import { fetchUser } from '../../helpers/getUser'
|
|
10
|
+
// import { ACCOUNT_QUERY_URL } from '../../constants'
|
|
12
11
|
import { addCacheHeaders } from '../../helpers/addCacheHeaders'
|
|
13
12
|
|
|
14
13
|
export async function getServerSideProps(context) {
|
|
@@ -18,16 +17,20 @@ export async function getServerSideProps(context) {
|
|
|
18
17
|
params: { section },
|
|
19
18
|
} = context
|
|
20
19
|
|
|
21
|
-
const mainSession = getMainSession(context.req.headers.cookie)
|
|
22
|
-
const session = sessionParser(mainSession)
|
|
20
|
+
// const mainSession = getMainSession(context.req.headers.cookie)
|
|
23
21
|
|
|
24
22
|
newrelic.setTransactionName(`Section: ${section}`)
|
|
25
|
-
const [
|
|
23
|
+
const [
|
|
24
|
+
{ data },
|
|
25
|
+
// user
|
|
26
|
+
] = await Promise.all([
|
|
26
27
|
apolloClient.query({
|
|
27
28
|
query: GET_PAGE,
|
|
28
29
|
variables: { channel: section, publisher: 'DEMO' },
|
|
29
30
|
}),
|
|
30
|
-
|
|
31
|
+
|
|
32
|
+
// TODO: Enable once Main add Subscriptions
|
|
33
|
+
// await fetchUser(mainSession, ACCOUNT_QUERY_URL),
|
|
31
34
|
])
|
|
32
35
|
|
|
33
36
|
addCacheHeaders(context.res)
|
|
@@ -35,7 +38,7 @@ export async function getServerSideProps(context) {
|
|
|
35
38
|
props: {
|
|
36
39
|
page: data.page,
|
|
37
40
|
isIndexPage: true,
|
|
38
|
-
user,
|
|
41
|
+
// user,
|
|
39
42
|
},
|
|
40
43
|
}
|
|
41
44
|
}
|
package/pages/index.tsx
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import newrelic from 'newrelic'
|
|
2
2
|
import {
|
|
3
3
|
createApolloClient,
|
|
4
|
-
|
|
5
|
-
getMainSession,
|
|
4
|
+
// getMainSession,
|
|
6
5
|
ClientTypes,
|
|
7
6
|
} from '@newskit-render/api'
|
|
8
7
|
import { GET_PAGE } from '../queries'
|
|
9
8
|
import SectionPage from '../components/section'
|
|
10
|
-
import { fetchUser } from '../helpers/getUser'
|
|
11
|
-
import { ACCOUNT_QUERY_URL } from '../constants'
|
|
9
|
+
// import { fetchUser } from '../helpers/getUser'
|
|
10
|
+
// import { ACCOUNT_QUERY_URL } from '../constants'
|
|
12
11
|
import { addCacheHeaders } from '../helpers/addCacheHeaders'
|
|
13
12
|
|
|
14
13
|
export async function getServerSideProps(context) {
|
|
@@ -17,15 +16,18 @@ export async function getServerSideProps(context) {
|
|
|
17
16
|
console.warn(context.req && context.req.headers)
|
|
18
17
|
|
|
19
18
|
const apolloClient = await createApolloClient(ClientTypes.nkapi)
|
|
20
|
-
const mainSession = getMainSession(context.req.headers.cookie)
|
|
21
|
-
const session = sessionParser(mainSession)
|
|
19
|
+
// const mainSession = getMainSession(context.req.headers.cookie)
|
|
22
20
|
|
|
23
|
-
const [
|
|
21
|
+
const [
|
|
22
|
+
{ data },
|
|
23
|
+
// user
|
|
24
|
+
] = await Promise.all([
|
|
24
25
|
apolloClient.query({
|
|
25
26
|
query: GET_PAGE,
|
|
26
27
|
variables: { channel: 'homepage', publisher: 'DEMO' },
|
|
27
28
|
}),
|
|
28
|
-
|
|
29
|
+
// TODO: Enable once Main add Subscriptions
|
|
30
|
+
// await fetchUser(mainSession, ACCOUNT_QUERY_URL),
|
|
29
31
|
])
|
|
30
32
|
|
|
31
33
|
addCacheHeaders(context.res)
|
|
@@ -33,7 +35,7 @@ export async function getServerSideProps(context) {
|
|
|
33
35
|
return {
|
|
34
36
|
props: {
|
|
35
37
|
page,
|
|
36
|
-
user,
|
|
38
|
+
// user: (user || null),
|
|
37
39
|
},
|
|
38
40
|
}
|
|
39
41
|
}
|
|
@@ -4,19 +4,6 @@ export const GET_USER_SUBSCRIPTION = gql`
|
|
|
4
4
|
query UserSubscription {
|
|
5
5
|
user {
|
|
6
6
|
email
|
|
7
|
-
vxInstances {
|
|
8
|
-
isActive
|
|
9
|
-
expiryDate
|
|
10
|
-
interactions {
|
|
11
|
-
... on SubscriptionPaymentInstance {
|
|
12
|
-
startAt
|
|
13
|
-
pastDue {
|
|
14
|
-
isPastDue
|
|
15
|
-
since
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
7
|
}
|
|
21
8
|
}
|
|
22
9
|
`
|
package/tsconfig.json
CHANGED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { render } from '@testing-library/react'
|
|
3
|
-
import SEOComponent, { limitString } from './index'
|
|
4
|
-
|
|
5
|
-
const getMeta = (metaName: string) => {
|
|
6
|
-
const metas = document.getElementsByTagName('meta')
|
|
7
|
-
for (let i = 0; i < metas.length; i += 1) {
|
|
8
|
-
if (
|
|
9
|
-
metas[i].getAttribute('name') === metaName ||
|
|
10
|
-
metas[i].getAttribute('property') === metaName
|
|
11
|
-
) {
|
|
12
|
-
return metas[i].getAttribute('content')
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
return false
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const getLink = (linkRel: string, attr: string) => {
|
|
19
|
-
const link = document.getElementsByTagName('link')
|
|
20
|
-
for (let i = 0; i < link.length; i += 1) {
|
|
21
|
-
if (link[i].getAttribute('rel') === linkRel) {
|
|
22
|
-
return link[i].getAttribute(attr)
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return false
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
jest.mock('next/head', () => {
|
|
29
|
-
return {
|
|
30
|
-
__esModule: true,
|
|
31
|
-
default: ({ children }: { children: Array<React.ReactElement> }) => {
|
|
32
|
-
return <>{children}</>
|
|
33
|
-
},
|
|
34
|
-
}
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
describe('SEOComponent tests', () => {
|
|
38
|
-
const Props = {
|
|
39
|
-
title: 'test title for SEOComponent',
|
|
40
|
-
description:
|
|
41
|
-
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed tincidunt blandit orci vel elementum. Integer malesuada quam in ullamcorper condimentum. Integer sollicitudin non enim sed posuere.',
|
|
42
|
-
url: 'https://test-url/test',
|
|
43
|
-
siteHost: 'https://siteHost.co.uk',
|
|
44
|
-
fbType: 'article',
|
|
45
|
-
fbImageUrl: 'https://test-uri/image',
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
test('SEOComponent with mandatory props', () => {
|
|
49
|
-
render(<SEOComponent {...Props} />, {
|
|
50
|
-
container: document.head,
|
|
51
|
-
})
|
|
52
|
-
expect(document.title).toBe(Props.title)
|
|
53
|
-
expect(getMeta('description')).toBe(limitString(Props.description, 155))
|
|
54
|
-
expect(getMeta('robots')).toBe('max-image-preview:large')
|
|
55
|
-
expect(getMeta('og:title')).toBe(Props.title)
|
|
56
|
-
expect(getMeta('og:type')).toBe(Props.fbType)
|
|
57
|
-
expect(getMeta('og:url')).toBe(Props.url)
|
|
58
|
-
expect(getMeta('twitter:card')).toBe('summary')
|
|
59
|
-
expect(getMeta('twitter:title')).toBe(Props.title)
|
|
60
|
-
expect(getMeta('twitter:site')).toBe(false)
|
|
61
|
-
expect(getMeta('twitter:description')).toBe(false)
|
|
62
|
-
expect(getMeta('twitter:image')).toBe(false)
|
|
63
|
-
expect(getMeta('twitter:image:alt')).toBe(false)
|
|
64
|
-
expect(getLink('canonical', 'href')).toBe(Props.url)
|
|
65
|
-
expect(getLink('alternate', 'href')).toBe(Props.siteHost)
|
|
66
|
-
expect(getLink('alternate', 'hreflang')).toBe('en')
|
|
67
|
-
})
|
|
68
|
-
|
|
69
|
-
test('SEOComponent with optional props', () => {
|
|
70
|
-
const extraProps = {
|
|
71
|
-
...Props,
|
|
72
|
-
gscId: 'asfdrtsdvs',
|
|
73
|
-
fbTitle: 'test facebook title',
|
|
74
|
-
twUsername: '@username',
|
|
75
|
-
twTitle: 'test twitter title',
|
|
76
|
-
twDescription:
|
|
77
|
-
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed tincidunt blandit orci vel elementum. Integer malesuada quam in ullamcorper condimentum.',
|
|
78
|
-
twImageUrl: 'https://test-uri/image-twitter',
|
|
79
|
-
twImageAlt: 'test alt',
|
|
80
|
-
hrefLang: 'en-GB',
|
|
81
|
-
maxImagePreview: 'standard' as 'none' | 'standard' | 'large',
|
|
82
|
-
}
|
|
83
|
-
render(<SEOComponent {...extraProps} />, {
|
|
84
|
-
container: document.head,
|
|
85
|
-
})
|
|
86
|
-
expect(document.title).toBe(extraProps.title)
|
|
87
|
-
expect(getMeta('description')).toBe(
|
|
88
|
-
limitString(extraProps.description, 155)
|
|
89
|
-
)
|
|
90
|
-
expect(getMeta('robots')).toBe(
|
|
91
|
-
`max-image-preview:${extraProps.maxImagePreview}`
|
|
92
|
-
)
|
|
93
|
-
expect(getMeta('og:title')).toBe(extraProps.fbTitle)
|
|
94
|
-
expect(getMeta('og:type')).toBe(extraProps.fbType)
|
|
95
|
-
expect(getMeta('og:url')).toBe(extraProps.url)
|
|
96
|
-
expect(getMeta('twitter:card')).toBe('summary')
|
|
97
|
-
expect(getMeta('twitter:title')).toBe(extraProps.twTitle)
|
|
98
|
-
expect(getMeta('twitter:site')).toBe(extraProps.twUsername)
|
|
99
|
-
expect(getMeta('twitter:description')).toBe(extraProps.twDescription)
|
|
100
|
-
expect(getMeta('twitter:image')).toBe(extraProps.twImageUrl)
|
|
101
|
-
expect(getMeta('twitter:image:alt')).toBe(extraProps.twImageAlt)
|
|
102
|
-
expect(getLink('canonical', 'href')).toBe(extraProps.url)
|
|
103
|
-
expect(getLink('alternate', 'href')).toBe(extraProps.siteHost)
|
|
104
|
-
expect(getLink('alternate', 'hreflang')).toBe(extraProps.hrefLang)
|
|
105
|
-
})
|
|
106
|
-
})
|
package/components/seo/index.tsx
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import Head from 'next/head'
|
|
3
|
-
import striptags from 'striptags'
|
|
4
|
-
|
|
5
|
-
export const limitString = (text: string, limit: number) =>
|
|
6
|
-
text.length > limit ? text.substr(0, limit) : text
|
|
7
|
-
|
|
8
|
-
type Props = {
|
|
9
|
-
title: string
|
|
10
|
-
description: string
|
|
11
|
-
url: string
|
|
12
|
-
siteHost: string
|
|
13
|
-
hrefLang?: string
|
|
14
|
-
maxImagePreview?: 'none' | 'standard' | 'large'
|
|
15
|
-
gscId?: string
|
|
16
|
-
fbTitle?: string
|
|
17
|
-
fbType: string
|
|
18
|
-
fbImageUrl: string
|
|
19
|
-
twUsername?: string
|
|
20
|
-
twTitle?: string
|
|
21
|
-
twDescription?: string
|
|
22
|
-
twImageUrl?: string
|
|
23
|
-
twImageAlt?: string
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const SEOComponent: React.FC<Props> = ({
|
|
27
|
-
title,
|
|
28
|
-
description,
|
|
29
|
-
url,
|
|
30
|
-
siteHost,
|
|
31
|
-
hrefLang = 'en',
|
|
32
|
-
maxImagePreview = 'large',
|
|
33
|
-
gscId,
|
|
34
|
-
fbTitle,
|
|
35
|
-
fbType,
|
|
36
|
-
fbImageUrl,
|
|
37
|
-
twUsername,
|
|
38
|
-
twTitle,
|
|
39
|
-
twDescription,
|
|
40
|
-
twImageUrl,
|
|
41
|
-
twImageAlt,
|
|
42
|
-
}) => (
|
|
43
|
-
<Head>
|
|
44
|
-
<title>{title}</title>
|
|
45
|
-
<meta
|
|
46
|
-
name="description"
|
|
47
|
-
content={limitString(striptags(description), 155)}
|
|
48
|
-
key="description"
|
|
49
|
-
/>
|
|
50
|
-
<link rel="canonical" href={url} />
|
|
51
|
-
<link rel="alternate" href={siteHost} hrefLang={hrefLang} />
|
|
52
|
-
<meta
|
|
53
|
-
name="robots"
|
|
54
|
-
content={`max-image-preview:${maxImagePreview}`}
|
|
55
|
-
key="max-image-preview"
|
|
56
|
-
/>
|
|
57
|
-
{gscId && <meta name="google-site-verification" content={gscId} />}
|
|
58
|
-
|
|
59
|
-
<meta property="og:title" content={fbTitle || title} key="ogtitle" />
|
|
60
|
-
<meta property="og:type" content={fbType} key="ogtype" />
|
|
61
|
-
<meta property="og:url" content={url} key="ogurl" />
|
|
62
|
-
<meta property="og:image" content={fbImageUrl} key="ogimage" />
|
|
63
|
-
|
|
64
|
-
<meta name="twitter:card" content="summary" key="twcard" />
|
|
65
|
-
<meta
|
|
66
|
-
name="twitter:title"
|
|
67
|
-
content={limitString(twTitle || title, 70)}
|
|
68
|
-
key="twtitle"
|
|
69
|
-
/>
|
|
70
|
-
{twUsername && (
|
|
71
|
-
<meta name="twitter:site" content={twUsername} key="twsite" />
|
|
72
|
-
)}
|
|
73
|
-
{twDescription && (
|
|
74
|
-
<meta
|
|
75
|
-
name="twitter:description"
|
|
76
|
-
content={limitString(striptags(twDescription), 200)}
|
|
77
|
-
key="twdescription"
|
|
78
|
-
/>
|
|
79
|
-
)}
|
|
80
|
-
{twImageUrl && (
|
|
81
|
-
<meta name="twitter:image" content={twImageUrl} key="twImage" />
|
|
82
|
-
)}
|
|
83
|
-
{twImageAlt && (
|
|
84
|
-
<meta name="twitter:image:alt" content={twImageAlt} key="twImageAlt" />
|
|
85
|
-
)}
|
|
86
|
-
</Head>
|
|
87
|
-
)
|
|
88
|
-
|
|
89
|
-
export default SEOComponent
|