@@ -45,7 +45,7 @@ export const Summary = () => {
45
45
const [ localChecks , setLocalChecks ] = React . useState ( { } ) ;
46
46
const [ checks , dispatch ] = React . useReducer ( reducer , initialState ) ;
47
47
48
- const { model, collectionType, id, form, contentType, components } = useContentManagerContext ( ) ;
48
+ const { layout , model, collectionType, id, form, contentType, components } = useContentManagerContext ( ) ;
49
49
const { values : modifiedData } = form ;
50
50
51
51
const { metaTitle, metaDescription, openGraph } = modifiedData . seo ;
@@ -56,39 +56,43 @@ export const Summary = () => {
56
56
documentId : id ,
57
57
} ) ;
58
58
59
- const getAllChecks = async ( modifiedData , components , contentType ) => {
59
+ const getAllChecks = async ( layout , modifiedData , components , contentType ) => {
60
60
const { data : defaultSettings } = await getSettings ( ) ;
61
61
62
+ const seoPropName = Object . entries ( layout . attributes ) . find ( ( [ , attr ] ) => attr . type === 'component' && attr . component === 'shared.seo' ) [ 0 ] ;
63
+ const seo = _ . get ( modifiedData , seoPropName , null ) ;
64
+
62
65
const { wordCount, keywordsDensity, emptyAltCount } = getRichTextData (
66
+ seo ,
63
67
modifiedData ,
64
68
components ,
65
69
contentType
66
70
) ;
67
71
68
72
let result = {
69
73
...( defaultSettings [ contentType ?. uid ] ?. seoChecks ?. metaTitle && {
70
- metaTitle : getMetaTitleCheckPreview ( modifiedData ) ,
74
+ metaTitle : getMetaTitleCheckPreview ( seo ) ,
71
75
} ) ,
72
76
...( defaultSettings [ contentType ?. uid ] ?. seoChecks ?. wordCount && {
73
77
wordCount : getWordCountPreview ( wordCount ) ,
74
78
} ) ,
75
79
...( defaultSettings [ contentType ?. uid ] ?. seoChecks ?. metaRobots && {
76
- metaRobots : metaRobotPreview ( modifiedData ) ,
80
+ metaRobots : metaRobotPreview ( seo ) ,
77
81
} ) ,
78
82
...( defaultSettings [ contentType ?. uid ] ?. seoChecks ?. openGraph && {
79
- openGraph : openGraphPreview ( modifiedData ) ,
83
+ openGraph : openGraphPreview ( seo ) ,
80
84
} ) ,
81
85
...( defaultSettings [ contentType ?. uid ] ?. seoChecks ?. canonicalUrl && {
82
- canonicalUrl : canonicalUrlPreview ( modifiedData ) ,
86
+ canonicalUrl : canonicalUrlPreview ( seo ) ,
83
87
} ) ,
84
88
...( defaultSettings [ contentType ?. uid ] ?. seoChecks ?. lastUpdatedAt && {
85
89
lastUpdatedAt : lastUpdatedAtPreview ( modifiedData ) ,
86
90
} ) ,
87
91
...( defaultSettings [ contentType ?. uid ] ?. seoChecks ?. structuredData && {
88
- structuredData : structuredDataPreview ( modifiedData ) ,
92
+ structuredData : structuredDataPreview ( seo ) ,
89
93
} ) ,
90
94
...( defaultSettings [ contentType ?. uid ] ?. seoChecks ?. metaDescription && {
91
- metaDescription : getMetaDescriptionPreview ( modifiedData ) ,
95
+ metaDescription : getMetaDescriptionPreview ( seo ) ,
92
96
} ) ,
93
97
...( defaultSettings [ contentType ?. uid ] ?. seoChecks ?. alternativeText && {
94
98
alternativeText : getAlternativeTextPreview ( emptyAltCount ) ,
@@ -105,7 +109,7 @@ export const Summary = () => {
105
109
const fetchChecks = async ( ) => {
106
110
if ( ! ( JSON . stringify ( localChecks ) === JSON . stringify ( checks ) ) ) {
107
111
if ( checks ?. preview ) {
108
- const status = await getAllChecks ( modifiedData , components , contentType ) ;
112
+ const status = await getAllChecks ( layout , modifiedData , components , contentType ) ;
109
113
110
114
dispatch ( {
111
115
type : 'UPDATE_FOR_PREVIEW' ,
@@ -147,7 +151,7 @@ export const Summary = () => {
147
151
</ Button >
148
152
</ Box >
149
153
</ Modal . Trigger >
150
- < BrowserPreview modifiedData = { modifiedData } />
154
+ < BrowserPreview layout = { layout } modifiedData = { modifiedData } />
151
155
</ Modal . Root >
152
156
) }
153
157
@@ -163,7 +167,7 @@ export const Summary = () => {
163
167
</ Button >
164
168
</ Box >
165
169
</ Modal . Trigger >
166
- < OpenGraphPreview modifiedData = { modifiedData } />
170
+ < OpenGraphPreview layout = { layout } modifiedData = { modifiedData } />
167
171
</ Modal . Root >
168
172
) }
169
173
@@ -181,6 +185,7 @@ export const Summary = () => {
181
185
</ Box >
182
186
</ Modal . Trigger >
183
187
< SeoChecks
188
+ layout = { layout }
184
189
updatedAt = { document ?. updatedAt ?? null }
185
190
modifiedData = { modifiedData }
186
191
components = { components }
0 commit comments