@newskit-render/standalone-components 2.0.1-alpha.0 → 2.1.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/README.md +219 -303
- package/dist/cjs/article-recommendations/components/AdPlaceholder.d.ts +9 -0
- package/dist/cjs/article-recommendations/components/AdPlaceholder.js +23 -0
- package/dist/cjs/article-recommendations/components/AdPlaceholder.js.map +1 -0
- package/dist/cjs/article-recommendations/components/ArticleGrid.js +12 -2
- package/dist/cjs/article-recommendations/components/ArticleGrid.js.map +1 -1
- package/dist/cjs/article-recommendations/components/ArticleRecommendationsProvider.js +41 -24
- package/dist/cjs/article-recommendations/components/ArticleRecommendationsProvider.js.map +1 -1
- package/dist/cjs/article-recommendations/components/RecommendedArticleList.js +2 -2
- package/dist/cjs/article-recommendations/components/RecommendedArticleList.js.map +1 -1
- package/dist/cjs/article-recommendations/components/index.d.ts +2 -1
- package/dist/cjs/article-recommendations/components/index.js +3 -1
- package/dist/cjs/article-recommendations/components/index.js.map +1 -1
- package/dist/cjs/article-recommendations/index.d.ts +1 -1
- package/dist/cjs/article-recommendations/index.js +5 -1
- package/dist/cjs/article-recommendations/index.js.map +1 -1
- package/dist/cjs/article-recommendations/types/index.d.ts +17 -2
- package/dist/cjs/article-recommendations/types/index.js.map +1 -1
- package/dist/esm/article-recommendations/components/AdPlaceholder.d.ts +9 -0
- package/dist/esm/article-recommendations/components/AdPlaceholder.js +18 -0
- package/dist/esm/article-recommendations/components/AdPlaceholder.js.map +1 -0
- package/dist/esm/article-recommendations/components/ArticleGrid.js +12 -2
- package/dist/esm/article-recommendations/components/ArticleGrid.js.map +1 -1
- package/dist/esm/article-recommendations/components/ArticleRecommendationsProvider.js +41 -24
- package/dist/esm/article-recommendations/components/ArticleRecommendationsProvider.js.map +1 -1
- package/dist/esm/article-recommendations/components/RecommendedArticleList.js +2 -2
- package/dist/esm/article-recommendations/components/RecommendedArticleList.js.map +1 -1
- package/dist/esm/article-recommendations/components/index.d.ts +2 -1
- package/dist/esm/article-recommendations/components/index.js +2 -1
- package/dist/esm/article-recommendations/components/index.js.map +1 -1
- package/dist/esm/article-recommendations/index.d.ts +1 -1
- package/dist/esm/article-recommendations/index.js +1 -1
- package/dist/esm/article-recommendations/index.js.map +1 -1
- package/dist/esm/article-recommendations/types/index.d.ts +17 -2
- package/dist/esm/article-recommendations/types/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -18,155 +18,21 @@ For npm:
|
|
|
18
18
|
|
|
19
19
|
## 1. Article recommendations
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
- Endpoint accepts the following params
|
|
24
|
-
|
|
25
|
-
- `articleId`
|
|
26
|
-
- `userId`
|
|
27
|
-
|
|
28
|
-
- Endpoint used in the following files in the `core` package
|
|
29
|
-
|
|
30
|
-
- `packages/core/pages/[section]/[articleId]/[articleSlug].tsx`
|
|
31
|
-
- `packages/core/pages/[section]/[articleId]/relatedArticles.tsx`
|
|
32
|
-
|
|
33
|
-
- recommendationsProvider: Provider function that accepts `articleId`, `publisher` and `userId`. The function will return an array of recommended articles.
|
|
34
|
-
|
|
35
|
-
- ArticleRecommendation: a component that accepts `article` and `size`, where
|
|
36
|
-
|
|
37
|
-
- `article` is an object with the following properties:
|
|
38
|
-
- href: string // mandatory
|
|
39
|
-
- title: string // mandatory
|
|
40
|
-
- text: string // optional
|
|
41
|
-
- `size` can be `large` or `small`.
|
|
42
|
-
- `overrides` can be used to pass overrides to the component to handle the styling
|
|
43
|
-
```typescript
|
|
44
|
-
overrides: {
|
|
45
|
-
spaceStack?: MQ<string>
|
|
46
|
-
card?: {
|
|
47
|
-
overrides?: {
|
|
48
|
-
stylePreset?: MQ<string>
|
|
49
|
-
mediaContainer?: {
|
|
50
|
-
spaceInline?: MQ<string>
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
media?: {
|
|
54
|
-
overrides: {
|
|
55
|
-
width?: string
|
|
56
|
-
height?: string
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
headline?: {
|
|
61
|
-
spaceStack?: MQ<string>
|
|
62
|
-
overrides: {
|
|
63
|
-
typographyPreset?: MQ<string>
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
text?: {
|
|
67
|
-
spaceStack?: MQ<string>
|
|
68
|
-
overrides: {
|
|
69
|
-
stylePreset?: MQ<string>
|
|
70
|
-
typographyPreset?: MQ<string>
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
```
|
|
21
|
+
Article recommendations implementation is split into two main components:
|
|
75
22
|
|
|
76
|
-
|
|
23
|
+
- ArticleRecommendationsProvider
|
|
24
|
+
- RecommendedArticleList
|
|
77
25
|
|
|
78
|
-
|
|
26
|
+
### Article Recommendations Provider
|
|
79
27
|
|
|
80
|
-
|
|
81
|
-
import React from 'react'
|
|
82
|
-
import { Block, Grid, Cell } from 'newskit'
|
|
83
|
-
import {
|
|
84
|
-
ArticleRecommendation,
|
|
85
|
-
recommendationsProvider,
|
|
86
|
-
Article,
|
|
87
|
-
} from '@newskit-render/standalone-components'
|
|
88
|
-
import { Publisher } from '@newskit-render/api'
|
|
89
|
-
|
|
90
|
-
const Recommendations: React.FC<{
|
|
91
|
-
recommendations: Article[]
|
|
92
|
-
}> = ({ recommendations }) => (
|
|
93
|
-
<Block data-testid="RelatedArticles">
|
|
94
|
-
<Grid xsMargin="space000">
|
|
95
|
-
{recommendations.map((article) => (
|
|
96
|
-
<Cell
|
|
97
|
-
key={article.title}
|
|
98
|
-
xs={12}
|
|
99
|
-
sm={6}
|
|
100
|
-
lg={3}
|
|
101
|
-
data-testid="RelatedArticlesVerticalCard"
|
|
102
|
-
>
|
|
103
|
-
<ArticleRecommendation article={article} size="large" />
|
|
104
|
-
</Cell>
|
|
105
|
-
))}
|
|
106
|
-
</Grid>
|
|
107
|
-
</Block>
|
|
108
|
-
)
|
|
109
|
-
|
|
110
|
-
export default Recommendations
|
|
111
|
-
|
|
112
|
-
export async function getServerSideProps(context) {
|
|
113
|
-
const recommendations = await recommendationsProvider({
|
|
114
|
-
articleId,
|
|
115
|
-
publisher: Publisher.SUN_UK,
|
|
116
|
-
})
|
|
117
|
-
|
|
118
|
-
return {
|
|
119
|
-
props: {
|
|
120
|
-
recommendations,
|
|
121
|
-
},
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
## 2. Article Grid
|
|
127
|
-
|
|
128
|
-
Article Grid - this is a grid element to display a list of articles with a customizable layout.
|
|
129
|
-
|
|
130
|
-
The component takes the following props:
|
|
131
|
-
|
|
132
|
-
```typescript
|
|
133
|
-
export type ArticleGridProps = {
|
|
134
|
-
overrides?: {
|
|
135
|
-
rowGap?: MQ<string>
|
|
136
|
-
columnGap?: MQ<string>
|
|
137
|
-
}
|
|
138
|
-
columnCount?: MQ<string>
|
|
139
|
-
size: 'large' | 'small'
|
|
140
|
-
articles: Article[]
|
|
141
|
-
}
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
### How to use
|
|
145
|
-
|
|
146
|
-
The `columnCount` prop will determine the number of columns in the grid, it supports media query as well.
|
|
147
|
-
|
|
148
|
-
```typescript
|
|
149
|
-
const ArticleList: React.FC<{
|
|
150
|
-
articles: Article[]
|
|
151
|
-
}> = ({ articles }) => (
|
|
152
|
-
<AricleGrid
|
|
153
|
-
columnCount={{ md: '1', lg: '2' }}
|
|
154
|
-
articles={articles}
|
|
155
|
-
size="large"
|
|
156
|
-
/>
|
|
157
|
-
)
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
## 3. Article Recommendations Provider
|
|
161
|
-
|
|
162
|
-
The purpose of this component is to hold the dpaTemplates in the context, fetch the recommended articles and map them to the appropriate templates.
|
|
28
|
+
This component as the name suggests is a React context provider. It will hold the digital personalisation templates (DPATemplates), fetch the recommended articles and map them to the appropriate template.
|
|
163
29
|
|
|
164
30
|
The component takes the following props.
|
|
165
31
|
|
|
166
32
|
```typescript
|
|
167
33
|
export type ArticleRecommendationsProviderProps = {
|
|
168
34
|
articleId?: string
|
|
169
|
-
context
|
|
35
|
+
context: ArticleRecommendationsProviderBaseContextType
|
|
170
36
|
children: ReactNode
|
|
171
37
|
config: Config
|
|
172
38
|
}
|
|
@@ -183,30 +49,41 @@ export type Config = {
|
|
|
183
49
|
}
|
|
184
50
|
```
|
|
185
51
|
|
|
186
|
-
The
|
|
52
|
+
The context holds the dpaTemplates dpaTemplate is a template, that holds information about the articles, ads and how they should be rendered on the screen.
|
|
187
53
|
|
|
188
54
|
```typescript
|
|
189
|
-
const
|
|
55
|
+
const context: ArticleRecommendationsProviderContextType = {
|
|
190
56
|
dpaTemplates: [
|
|
191
57
|
{
|
|
192
58
|
templateId: 'list-1',
|
|
193
59
|
columnCount: '1',
|
|
194
60
|
size: 'small',
|
|
195
|
-
|
|
196
|
-
|
|
61
|
+
{
|
|
62
|
+
templateId: 'list-1',
|
|
63
|
+
columnCount: '1',
|
|
64
|
+
size: 'small',
|
|
65
|
+
recommendedArticlesCount: 4,
|
|
66
|
+
ads: {
|
|
67
|
+
count: 3,
|
|
68
|
+
articlesMargin: 2,
|
|
69
|
+
options: {
|
|
70
|
+
id: 'dynamic-mpu',
|
|
71
|
+
className: 'nuk-ad-placeholder',
|
|
72
|
+
dataAdLabel: 'dynamicMpus',
|
|
73
|
+
},
|
|
74
|
+
},
|
|
197
75
|
},
|
|
198
76
|
{
|
|
199
77
|
templateId: 'list-2',
|
|
200
78
|
columnCount: { xs: '1', sm: '2', lg: '4' },
|
|
201
79
|
size: 'large',
|
|
202
|
-
|
|
203
|
-
adlibraryMPU: { totalArticlesCount: 0 },
|
|
80
|
+
recommendedArticlesCount: 8,
|
|
204
81
|
},
|
|
205
82
|
],
|
|
206
83
|
}
|
|
207
84
|
```
|
|
208
85
|
|
|
209
|
-
|
|
86
|
+
dpa template props:
|
|
210
87
|
|
|
211
88
|
`templateId` template identifier used to uniquely identify the template
|
|
212
89
|
|
|
@@ -214,11 +91,60 @@ Template props:
|
|
|
214
91
|
|
|
215
92
|
`size` the size of the articles
|
|
216
93
|
|
|
217
|
-
`
|
|
94
|
+
`recommendedArticlesCount` is the number of the recommended articles
|
|
95
|
+
`ads` is an optional object containing data for ads
|
|
96
|
+
Ads props:
|
|
97
|
+
`count` the number of ads that we want to have in the current template
|
|
98
|
+
`articlesMargin` is the number of articles that you want to have in between the ads
|
|
99
|
+
`options.id` will contain the prefix of the ad id(E.G dynamic-mpu-1, dynamic-mpu-2 etc.)
|
|
100
|
+
`options.className` is the class name used for all ads
|
|
101
|
+
`options.dataAdLabel` is the data attribute used for all ad
|
|
102
|
+
|
|
103
|
+
### RecommendedArticleList
|
|
104
|
+
|
|
105
|
+
This component should be a children of Article Recommendations provider. It's purpose is to render all articles and ads from a specific dpa template based on a template id
|
|
218
106
|
|
|
219
107
|
### Usage
|
|
220
108
|
|
|
109
|
+
In order to use Article recommendations provider and recommended articles list you must wrap your page or the section where you want to display recommendations.
|
|
110
|
+
|
|
111
|
+
You need to pass to Article recommendations provider the context object, that holds dpa templates and the config for Newskit API.
|
|
112
|
+
|
|
113
|
+
Then you can use RecommenedArticleList as a children of ArticleRecommendationsProvider and pass it a template id, that is used as an id in one of the dpa templates.
|
|
114
|
+
|
|
115
|
+
See example below:
|
|
116
|
+
|
|
221
117
|
```typescript
|
|
118
|
+
|
|
119
|
+
const context: ArticleRecommendationsProviderContextType = {
|
|
120
|
+
dpaTemplates: [
|
|
121
|
+
{
|
|
122
|
+
templateId: 'list-1',
|
|
123
|
+
columnCount: '1',
|
|
124
|
+
size: 'small',
|
|
125
|
+
{
|
|
126
|
+
templateId: 'list-1',
|
|
127
|
+
columnCount: '1',
|
|
128
|
+
size: 'small',
|
|
129
|
+
recommendedArticlesCount: 4,
|
|
130
|
+
ads: {
|
|
131
|
+
count: 3,
|
|
132
|
+
articlesMargin: 2,
|
|
133
|
+
options: {
|
|
134
|
+
id: 'dynamic-mpu',
|
|
135
|
+
className: 'nuk-ad-placeholder',
|
|
136
|
+
dataAdLabel: 'dynamicMpus',
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
templateId: 'list-2',
|
|
142
|
+
columnCount: { xs: '1', sm: '2', lg: '4' },
|
|
143
|
+
size: 'large',
|
|
144
|
+
recommendedArticlesCount: 8,
|
|
145
|
+
},
|
|
146
|
+
],
|
|
147
|
+
}
|
|
222
148
|
const Article: React.FC<ArticleSlug> = ({
|
|
223
149
|
universalArticle,
|
|
224
150
|
articleURL,
|
|
@@ -229,8 +155,10 @@ const Article: React.FC<ArticleSlug> = ({
|
|
|
229
155
|
articleId,
|
|
230
156
|
config,
|
|
231
157
|
}) => (
|
|
232
|
-
<ArticleRecommendationsProvider articleId={articleId} config={config}>
|
|
233
|
-
|
|
158
|
+
<ArticleRecommendationsProvider articleId={articleId} config={config} context={context}>
|
|
159
|
+
<RecommendedArticleList templateId="list-1" />
|
|
160
|
+
...
|
|
161
|
+
<RecommendedArticleList templateId="list-2" />
|
|
234
162
|
</ArticleRecommendationsProvider>
|
|
235
163
|
)
|
|
236
164
|
|
|
@@ -247,59 +175,40 @@ export async function getServerSideProps(context) {
|
|
|
247
175
|
}
|
|
248
176
|
```
|
|
249
177
|
|
|
250
|
-
|
|
178
|
+
<!--
|
|
179
|
+
## 2. Article Grid
|
|
180
|
+
|
|
181
|
+
Article Grid - this is a grid element to display a list of articles with a customizable layout.
|
|
251
182
|
|
|
252
|
-
|
|
183
|
+
The component takes the following props:
|
|
253
184
|
|
|
254
185
|
```typescript
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
},
|
|
264
|
-
{
|
|
265
|
-
templateId: 'list-2',
|
|
266
|
-
columnCount: { xs: '1', sm: '2', lg: '4' },
|
|
267
|
-
size: 'large',
|
|
268
|
-
recommendedArticles: [{ article }, ...], //8 articles
|
|
269
|
-
adlibraryMPU: [],
|
|
270
|
-
},
|
|
271
|
-
],
|
|
186
|
+
export type ArticleGridProps = {
|
|
187
|
+
overrides?: {
|
|
188
|
+
rowGap?: MQ<string>
|
|
189
|
+
columnGap?: MQ<string>
|
|
190
|
+
}
|
|
191
|
+
columnCount?: MQ<string>
|
|
192
|
+
size: 'large' | 'small'
|
|
193
|
+
articles: Article[]
|
|
272
194
|
}
|
|
273
195
|
```
|
|
274
196
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
```typescript
|
|
278
|
-
const ArticleList: React.FC<{ templateId: string }> = ({ templateId }) => {
|
|
279
|
-
const context = useContext(
|
|
280
|
-
ArticleRecommendationsProviderContext
|
|
281
|
-
) as ArticleRecommendationsProviderContextTypeWithArticles
|
|
282
|
-
|
|
283
|
-
const dpaTemplate = context.dpaTemplates.find(
|
|
284
|
-
(dpaTemplate) => dpaTemplate.templateId === templateId
|
|
285
|
-
)
|
|
286
|
-
|
|
287
|
-
if (!dpaTemplate) {
|
|
288
|
-
return null
|
|
289
|
-
}
|
|
197
|
+
### How to use
|
|
290
198
|
|
|
291
|
-
|
|
292
|
-
return (
|
|
293
|
-
<AricleGrid
|
|
294
|
-
articles={recommendedArticles}
|
|
295
|
-
columnCount={columnCount}
|
|
296
|
-
size={size}
|
|
297
|
-
/>
|
|
298
|
-
)
|
|
299
|
-
}
|
|
199
|
+
The `columnCount` prop will determine the number of columns in the grid, it supports media query as well.
|
|
300
200
|
|
|
301
|
-
|
|
302
|
-
|
|
201
|
+
```typescript
|
|
202
|
+
const ArticleList: React.FC<{
|
|
203
|
+
articles: Article[]
|
|
204
|
+
}> = ({ articles }) => (
|
|
205
|
+
<AricleGrid
|
|
206
|
+
columnCount={{ md: '1', lg: '2' }}
|
|
207
|
+
articles={articles}
|
|
208
|
+
size="large"
|
|
209
|
+
/>
|
|
210
|
+
)
|
|
211
|
+
``` -->
|
|
303
212
|
|
|
304
213
|
## 4. Help-hub:
|
|
305
214
|
|
|
@@ -328,7 +237,7 @@ For obtaining the Algolia credentials, ask your manager
|
|
|
328
237
|
If your team does not have account, you will have to request or create such
|
|
329
238
|
|
|
330
239
|
Ask CSP for futher information about populating the data in Algolia. They can assist for getting the data from Salesforce.
|
|
331
|
-
Slack channel: [#cps-support](https://newsuktechnology.slack.com/archives/CM0M0NFEE)
|
|
240
|
+
Slack channel: [#cps-support](https://newsuktechnology.slack.com/archives/CM0M0NFEE)
|
|
332
241
|
|
|
333
242
|
### How to use
|
|
334
243
|
|
|
@@ -461,163 +370,170 @@ export const baseContext: BaseContextOptions = {
|
|
|
461
370
|
},
|
|
462
371
|
}
|
|
463
372
|
```
|
|
373
|
+
|
|
464
374
|
2.2 Properties of BaseContextOptions
|
|
465
375
|
|
|
466
|
-
|
|
376
|
+
1. baseUrl - relative url when the help hub landing page lives
|
|
467
377
|
|
|
468
|
-
|
|
378
|
+
2. seo: - Used in the Header component
|
|
469
379
|
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
380
|
+
- title: string
|
|
381
|
+
- description: string
|
|
382
|
+
- url: string
|
|
383
|
+
- siteHost: string
|
|
384
|
+
- hrefLang: string
|
|
475
385
|
|
|
476
|
-
|
|
386
|
+
3. navigationPrimary - Global property changes nav links in top banner area - Array of nav objects or false to have no nav
|
|
477
387
|
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
388
|
+
- nav?:
|
|
389
|
+
- text: string
|
|
390
|
+
- link: string
|
|
391
|
+
- icon: React.ReactElement<NewsKitIconProps>
|
|
392
|
+
- ariaLabel?: string
|
|
393
|
+
- title?: string
|
|
394
|
+
- logoSrc?: string (path to logo.svg)
|
|
395
|
+
- logoWidth?: string (width of logo)
|
|
396
|
+
- titlePosition?: string (uses css top property to ajust title position)
|
|
487
397
|
|
|
488
|
-
|
|
398
|
+
4. header - Property used to change the title value and styles of each page
|
|
489
399
|
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
400
|
+
- overlineOverrides
|
|
401
|
+
- typographyPreset: MQ
|
|
402
|
+
- stylePreset: MQ
|
|
403
|
+
- spaceStack: MQ
|
|
404
|
+
- title: string
|
|
405
|
+
- titleOverrides
|
|
406
|
+
|
|
407
|
+
- typographyPreset: MQ
|
|
408
|
+
- stylePreset: MQ
|
|
409
|
+
- spaceStack: string
|
|
410
|
+
- as: h1 | h2 | h3 | h4 | h5 | h6
|
|
411
|
+
|
|
412
|
+
- description: string
|
|
413
|
+
- descriptionOverrides
|
|
414
|
+
|
|
415
|
+
- typographyPreset: MQ
|
|
416
|
+
- stylePreset: MQ
|
|
417
|
+
- spaceStack: string
|
|
418
|
+
|
|
419
|
+
- backButtonOverrides
|
|
420
|
+
|
|
421
|
+
- spaceStack: MQ
|
|
422
|
+
- stylePreset: MQ
|
|
423
|
+
- typographyPreset: MQ
|
|
424
|
+
- iconSize: MQ
|
|
515
425
|
|
|
516
|
-
|
|
426
|
+
- spaceStack: MQ
|
|
427
|
+
- showDivider: boolean
|
|
517
428
|
|
|
518
|
-
|
|
429
|
+
5. searchBar: Property used to style the search bar container
|
|
519
430
|
|
|
520
|
-
|
|
431
|
+
- spaceStack: MQ
|
|
521
432
|
|
|
522
|
-
|
|
523
|
-
- spaceStack: MQ
|
|
524
|
-
|
|
525
|
-
7. articleNotFound: string - Warning message for when the article is not found
|
|
433
|
+
6. contentListView: Property used to style the results table
|
|
526
434
|
|
|
527
|
-
|
|
435
|
+
- introduction: - Used to style the table title
|
|
436
|
+
- spaceStack: MQ
|
|
528
437
|
|
|
529
|
-
|
|
438
|
+
7. articleNotFound: string - Warning message for when the article is not found
|
|
530
439
|
|
|
531
|
-
|
|
440
|
+
8. searchResultEmpty: string - Warning message for when there is not search string
|
|
532
441
|
|
|
533
|
-
|
|
442
|
+
9. spaceStack: MQ
|
|
443
|
+
|
|
444
|
+
10. inputPlaceholder: string - Search bar placeholder
|
|
445
|
+
|
|
446
|
+
11. footer: Global property
|
|
534
447
|
|
|
535
448
|
- menuItemArray: [
|
|
536
449
|
{
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
450
|
+
text: string
|
|
451
|
+
href: string
|
|
452
|
+
id: integer,
|
|
540
453
|
}
|
|
541
|
-
|
|
454
|
+
]
|
|
542
455
|
- legalText: string
|
|
543
456
|
|
|
544
|
-
|
|
457
|
+
12. footerOverrides: Global property
|
|
545
458
|
|
|
546
459
|
- ariaLabel: string
|
|
547
460
|
- menuItemOverrides:
|
|
461
|
+
|
|
548
462
|
- stylePreset: MQ
|
|
549
463
|
- typographyPreset: MQ
|
|
550
|
-
|
|
464
|
+
|
|
551
465
|
- menuOverrides:
|
|
466
|
+
|
|
552
467
|
- spaceStack: MQ
|
|
553
468
|
- backgroundColor: MQ
|
|
554
469
|
- borderColor: MQ
|
|
555
470
|
- padding: MQ
|
|
556
|
-
|
|
471
|
+
|
|
557
472
|
- legalTextOverrides:
|
|
558
473
|
- spaceStack: MQ
|
|
559
474
|
- stylePreset: MQ
|
|
560
475
|
- typographyPreset: MQ
|
|
561
476
|
- padding: MQ
|
|
562
477
|
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
As said above, help hub consists of three pages and we will take a look on how to add each one of them individually.
|
|
478
|
+
As said above, help hub consists of three pages and we will take a look on how to add each one of them individually.
|
|
567
479
|
|
|
568
480
|
Each page extend the above BaseContextOptions with their own properties:
|
|
569
481
|
|
|
570
482
|
2.3 HelpHubLandingPageContextOptions
|
|
571
483
|
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
484
|
+
1. articlesTabelInfo
|
|
485
|
+
- title: string
|
|
486
|
+
- titleOverrides
|
|
487
|
+
- typographyPreset: MQ
|
|
488
|
+
- stylePreset: MQ
|
|
489
|
+
- spaceStack: string
|
|
490
|
+
- as: h1 | h2 | h3 | h4 | h5 | h6
|
|
491
|
+
2. mostReadArticles: [
|
|
492
|
+
{
|
|
493
|
+
- title: string
|
|
494
|
+
- objectID: string
|
|
495
|
+
}
|
|
496
|
+
]
|
|
585
497
|
|
|
586
498
|
2.4 ResultsPageContextOptions
|
|
587
499
|
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
500
|
+
1. hits: [
|
|
501
|
+
{
|
|
502
|
+
- title: string
|
|
503
|
+
- objectID: string
|
|
504
|
+
- content: string
|
|
505
|
+
}
|
|
506
|
+
]
|
|
507
|
+
2. introductionProps:
|
|
508
|
+
|
|
509
|
+
- title: string
|
|
510
|
+
- titleOverrides
|
|
511
|
+
- typographyPreset: MQ
|
|
512
|
+
- stylePreset: MQ
|
|
513
|
+
- spaceStack: string
|
|
514
|
+
- as: h1 | h2 | h3 | h4 | h5 | h6
|
|
515
|
+
- description: string
|
|
516
|
+
- showDivider: boolean
|
|
517
|
+
|
|
518
|
+
3. stylePreset: MQ<string>
|
|
519
|
+
4. showDividerByBreakpoint: boolean
|
|
606
520
|
|
|
607
521
|
2.5 ArticlePageContextOptions
|
|
608
522
|
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
523
|
+
1. introductionProps:
|
|
524
|
+
|
|
525
|
+
- titleOverrides
|
|
526
|
+
- typographyPreset: MQ
|
|
527
|
+
- stylePreset: MQ
|
|
528
|
+
- spaceStack: string
|
|
529
|
+
- as: h1 | h2 | h3 | h4 | h5 | h6
|
|
530
|
+
|
|
531
|
+
2. title: string
|
|
532
|
+
3. content: string
|
|
617
533
|
|
|
618
534
|
Standalone-components package exports page components, page context, page context types (PageContextOptions) and a provider function for each page.
|
|
619
535
|
|
|
620
|
-
2.6 Help-Hub Landing page.
|
|
536
|
+
2.6 Help-Hub Landing page.
|
|
621
537
|
|
|
622
538
|
As stated above, landing page will display the most read articles. For now these articles are hardcoded and need to be passed to the Landing page (see example below). These articles must be already imported in Algolia in order for them to work.
|
|
623
539
|
|
|
@@ -764,7 +680,7 @@ export const getServerSideProps = async (context) => {
|
|
|
764
680
|
}
|
|
765
681
|
```
|
|
766
682
|
|
|
767
|
-
By default ResultsPage will return up to 20 results. This can be changed by adding a second parameter to `helpHubResultsProvider`
|
|
683
|
+
By default ResultsPage will return up to 20 results. This can be changed by adding a second parameter to `helpHubResultsProvider`
|
|
768
684
|
|
|
769
685
|
```typescript
|
|
770
686
|
export const getServerSideProps = async (context) => {
|
|
@@ -837,4 +753,4 @@ export const getServerSideProps = async (context) => {
|
|
|
837
753
|
|
|
838
754
|
return helpHubArticleProvider(context)
|
|
839
755
|
}
|
|
840
|
-
```
|
|
756
|
+
```
|