@@ -20,13 +20,13 @@ function renderReferencedComponent(ref) {
20
20
return < Component { ...ref } />
21
21
}
22
22
23
- const options = {
23
+ const makeOptions = ( { assetBlockMap , entryBlockMap , entryInlineMap } ) => ( {
24
24
renderMark : {
25
25
[ MARKS . BOLD ] : text => < strong data-cy-strong > { text } </ strong > ,
26
26
} ,
27
27
renderNode : {
28
28
[ BLOCKS . EMBEDDED_ASSET ] : node => {
29
- const asset = node . data . target
29
+ const asset = assetBlockMap . get ( node ? .data ? .target ?. sys . id )
30
30
if ( asset . gatsbyImageData ) {
31
31
return < GatsbyImage image = { asset . gatsbyImageData } />
32
32
}
@@ -40,7 +40,7 @@ const options = {
40
40
)
41
41
} ,
42
42
[ BLOCKS . EMBEDDED_ENTRY ] : node => {
43
- const entry = node ?. data ?. target
43
+ const entry = entryBlockMap . get ( node ?. data ?. target ?. sys . id )
44
44
if ( ! entry ) {
45
45
throw new Error (
46
46
`Entity not available for node:\n${ JSON . stringify ( node , null , 2 ) } `
@@ -49,7 +49,7 @@ const options = {
49
49
return renderReferencedComponent ( entry )
50
50
} ,
51
51
[ INLINES . EMBEDDED_ENTRY ] : node => {
52
- const entry = node . data . target
52
+ const entry = entryInlineMap . get ( node ? .data ? .target ?. sys . id )
53
53
if ( entry . __typename === "ContentfulText" ) {
54
54
return (
55
55
< span data-cy-id = "inline-text" >
@@ -64,7 +64,7 @@ const options = {
64
64
)
65
65
} ,
66
66
} ,
67
- }
67
+ } )
68
68
69
69
const RichTextPage = ( { data } ) => {
70
70
const defaultEntries = data . default . nodes
@@ -77,7 +77,7 @@ const RichTextPage = ({ data }) => {
77
77
return (
78
78
< div data-cy-id = { slug } key = { id } >
79
79
< h2 > { title } </ h2 >
80
- { renderRichText ( richText , options ) }
80
+ { renderRichText ( richText , makeOptions ) }
81
81
< hr />
82
82
</ div >
83
83
)
@@ -89,7 +89,7 @@ const RichTextPage = ({ data }) => {
89
89
return (
90
90
< div data-cy-id = { `english-${ slug } ` } key = { id } >
91
91
< h2 > { title } </ h2 >
92
- { renderRichText ( richTextLocalized , options ) }
92
+ { renderRichText ( richTextLocalized , makeOptions ) }
93
93
< hr />
94
94
</ div >
95
95
)
@@ -101,7 +101,7 @@ const RichTextPage = ({ data }) => {
101
101
return (
102
102
< div data-cy-id = { `german-${ slug } ` } key = { id } >
103
103
< h2 > { title } </ h2 >
104
- { renderRichText ( richTextLocalized , options ) }
104
+ { renderRichText ( richTextLocalized , makeOptions ) }
105
105
< hr />
106
106
</ div >
107
107
)
@@ -125,76 +125,92 @@ export const pageQuery = graphql`
125
125
id
126
126
title
127
127
richText {
128
- raw
129
- references {
130
- __typename
131
- sys {
132
- id
133
- }
134
- ... on ContentfulAsset {
135
- contentful_id
136
- gatsbyImageData(width: 200)
137
- }
138
- ... on ContentfulText {
139
- title
140
- short
141
- }
142
- ... on ContentfulLocation {
143
- location {
144
- lat
145
- lon
128
+ json
129
+ links {
130
+ assets {
131
+ block {
132
+ sys {
133
+ id
134
+ }
135
+ gatsbyImageData(width: 200)
146
136
}
147
137
}
148
- ... on ContentfulContentReference {
149
- title
150
- one {
138
+ entries {
139
+ block {
151
140
__typename
152
141
sys {
153
142
id
143
+ type
154
144
}
155
145
... on ContentfulText {
156
146
title
157
147
short
158
148
}
149
+ ... on ContentfulLocation {
150
+ location {
151
+ lat
152
+ lon
153
+ }
154
+ }
159
155
... on ContentfulContentReference {
160
156
title
161
157
one {
158
+ __typename
159
+ sys {
160
+ id
161
+ }
162
+ ... on ContentfulText {
163
+ title
164
+ short
165
+ }
162
166
... on ContentfulContentReference {
163
167
title
168
+ one {
169
+ ... on ContentfulContentReference {
170
+ title
171
+ }
172
+ }
173
+ many {
174
+ ... on ContentfulContentReference {
175
+ title
176
+ }
177
+ }
164
178
}
165
179
}
166
180
many {
181
+ __typename
182
+ sys {
183
+ id
184
+ }
185
+ ... on ContentfulText {
186
+ title
187
+ short
188
+ }
189
+ ... on ContentfulNumber {
190
+ title
191
+ integer
192
+ }
167
193
... on ContentfulContentReference {
168
194
title
195
+ one {
196
+ ... on ContentfulContentReference {
197
+ title
198
+ }
199
+ }
200
+ many {
201
+ ... on ContentfulContentReference {
202
+ title
203
+ }
204
+ }
169
205
}
170
206
}
171
207
}
172
208
}
173
- many {
209
+ inline {
174
210
__typename
175
211
sys {
176
212
id
177
- }
178
- ... on ContentfulText {
179
- title
180
- short
181
- }
182
- ... on ContentfulNumber {
183
- title
184
- integer
185
- }
186
- ... on ContentfulContentReference {
187
- title
188
- one {
189
- ... on ContentfulContentReference {
190
- title
191
- }
192
- }
193
- many {
194
- ... on ContentfulContentReference {
195
- title
196
- }
197
- }
213
+ type
198
214
}
199
215
}
200
216
}
@@ -213,7 +229,7 @@ export const pageQuery = graphql`
213
229
id
214
230
title
215
231
richTextLocalized {
216
- raw
232
+ json
217
233
}
218
234
}
219
235
}
@@ -228,7 +244,7 @@ export const pageQuery = graphql`
228
244
id
229
245
title
230
246
richTextLocalized {
231
- raw
247
+ json
232
248
}
233
249
}
234
250
}
0 commit comments