1
1
import { gql , pocketRequest } from '@common/utilities/pocket-request'
2
2
import { getErrorMessage } from '@common/utilities/error-handler'
3
3
import { SUPPORTED_LOCALES } from '@common/localization'
4
+ import { FRAGMENT_ITEM_PREVIEW } from '../_fragments/preview'
4
5
5
6
// Types
6
7
import type { CorpusSlate , CorpusRecommendation , CorpusSlateLineup } from '@common/types/pocket'
@@ -33,16 +34,8 @@ const getHomeQuery = gql`
33
34
recommendations(count: 12) {
34
35
id
35
36
corpusItem {
36
- image {
37
- url
38
- }
39
- url
40
- title
41
- excerpt
42
- language
43
- publisher
44
- authors {
45
- name
37
+ preview {
38
+ ...ItemPreview
46
39
}
47
40
}
48
41
reason {
@@ -53,6 +46,8 @@ const getHomeQuery = gql`
53
46
}
54
47
}
55
48
}
49
+
50
+ ${ FRAGMENT_ITEM_PREVIEW }
56
51
`
57
52
58
53
/**
@@ -93,21 +88,22 @@ export async function getHomeSlates(locale: string): Promise<HomeQueryResponse |
93
88
function getItemsFromSlate ( { recommendations } : { recommendations : CorpusRecommendation [ ] } ) {
94
89
return recommendations . reduce ( ( previous , current ) => {
95
90
const corpusItem = current ?. corpusItem
91
+ const preview = current ?. corpusItem ?. preview
96
92
const topic = current ?. reason ?. name
97
93
const corpusRecommendationId = current ?. id
98
94
if ( ! corpusItem ) return previous
99
95
return {
100
96
...previous ,
101
97
[ corpusRecommendationId ] : {
102
- ...corpusItem ,
103
- externalUrl : corpusItem . url ,
104
- saveUrl : corpusItem . url ,
98
+ ...preview ,
99
+ externalUrl : preview . url ,
100
+ saveUrl : preview . url ,
105
101
id : corpusRecommendationId ,
106
102
itemId : corpusRecommendationId ,
107
103
topic,
108
104
corpusRecommendationId,
109
105
analyticsData : {
110
- url : corpusItem . url ,
106
+ url : preview . url ,
111
107
corpusRecommendationId
112
108
}
113
109
}
0 commit comments