14
14
</form >
15
15
</h1 >
16
16
<template v-if =" ! editing && domain " >
17
- <div v-if =" status === 'pending' || results"
18
- class =" flex flex-row flex-wrap gap-4 lg:flex-row justify-around w-full" >
19
- <ProgressRing size =" normal" :value =" results && status !== 'pending' ? results.performance : undefined"
20
- caption =" performance" />
21
- <ProgressRing size =" normal" :value =" results && status !== 'pending' ? results.accessibility : undefined"
22
- caption =" accessibility" />
23
- <ProgressRing size =" normal" :value =" results && status !== 'pending' ? results.bestPractices : undefined"
24
- caption =" best practices" />
25
- <ProgressRing size =" normal" :value =" results && status !== 'pending' ? results.seo : undefined" caption =" SEO" />
26
- </div >
17
+ <template v-if =" status === ' pending' || results " >
18
+ <div class =" flex flex-row flex-wrap gap-4 lg:flex-row justify-around w-full" >
19
+ <template v-if =" status === ' pending' || results ?.crux " >
20
+ <ProgressRing size =" normal" :value =" results?.crux && status !== 'pending' ? results.crux.cwv : undefined"
21
+ caption =" core web vitals" />
22
+ <Histogram size =" normal" :value =" results?.crux && status !== 'pending' ? results.crux.lcp : undefined"
23
+ caption =" LCP" />
24
+ <Histogram size =" normal" :value =" results?.crux && status !== 'pending' ? results.crux.cls : undefined"
25
+ caption =" CLS" />
26
+ <Histogram size =" normal" :value =" results?.crux && status !== 'pending' ? results.crux.inp : undefined"
27
+ caption =" INP" />
28
+ </template >
29
+ <template v-else-if =" results " >
30
+ <ProgressRing size =" normal" :value =" results.lighthouse.performance" caption =" performance" />
31
+ <ProgressRing size =" normal" :value =" results.lighthouse.accessibility" caption =" accessibility" />
32
+ <ProgressRing size =" normal" :value =" results.lighthouse.bestPractices" caption =" best practices" />
33
+ <ProgressRing size =" normal" :value =" results.lighthouse.seo" caption =" SEO" />
34
+ </template >
35
+ </div >
36
+ <div v-if =" status === 'pending' || (results && results.crux)"
37
+ class =" flex flex-row flex-wrap gap-4 lg:flex-row justify-around w-full border border-green-700 border-2 rounded-lg p-4" >
38
+ <span class =" flex flex-row gap-2" >
39
+ <span class =" font-bold" >{{ results && status !== 'pending' ? results.lighthouse.performance.toFixed(0) :
40
+ undefined
41
+ }}</span >
42
+ <span >performance</span >
43
+ </span >
44
+ <span class =" flex flex-row gap-2" >
45
+ <span class =" font-bold" >{{ results && status !== 'pending' ? results.lighthouse.accessibility.toFixed(0) :
46
+ undefined
47
+ }}</span >
48
+ <span >accessibility</span >
49
+ </span >
50
+ <span class =" flex flex-row gap-2" >
51
+ <span class =" font-bold" >{{ results && status !== 'pending' ? results.lighthouse.bestPractices.toFixed(0) :
52
+ undefined
53
+ }}</span >
54
+ <span >best practices</span >
55
+ </span >
56
+ <span class =" flex flex-row gap-2" >
57
+ <span class =" font-bold" >{{ results && status !== 'pending' ? results.lighthouse.seo.toFixed(0) : undefined
58
+ }}</span >
59
+ <span >SEO</span >
60
+ </span >
61
+ </div >
62
+ </template >
27
63
<div v-else-if =" domain" >
28
64
No results could be fetched. Is it a valid domain?
29
65
</div >
33
69
:href =" shareLink" @click.prevent =" nativeShare" >
34
70
Share results
35
71
</NuxtLink >
36
- <a :href =" `https://pagespeed.web.dev/analysis?url=https://${domain}`"
72
+ <a v-if =" results?.crux"
73
+ :href =" `https://lookerstudio.google.com/c/u/0/reporting/bbc5698d-57bb-4969-9e07-68810b9fa348/page/keDQB?params=%7B%22origin%22:%22https://${domain}%22%7D`"
74
+ class =" self-start underline text-gray-400 hover:text-green-400 focus:text-green-400 active:text-green-400" >
75
+ Explore full results in the CrUX Dashboard » ;
76
+ </a >
77
+ <a v-else :href =" `https://pagespeed.web.dev/analysis?url=https://${domain}`"
37
78
class =" self-start underline text-gray-400 hover:text-green-400 focus:text-green-400 active:text-green-400" >
38
79
See full results on PageSpeed Insights » ;
39
80
</a >
40
- <span v-if =" results?.timestamp" class =" text-gray-400" >
81
+ <span v-if =" results?.crux?.timestamp || results?.lighthouse?. timestamp" class =" text-gray-400" >
41
82
Last updated at
42
- <NuxtTime :datetime =" results.timestamp" dateStyle =" full" timeStyle =" medium" />.
83
+ <NuxtTime :datetime =" results.crux?.timestamp || results.lighthouse.timestamp" dateStyle =" full"
84
+ timeStyle =" medium" />.
43
85
</span >
44
86
</div >
45
87
</template >
@@ -83,7 +125,14 @@ function enableEditing () {
83
125
}, { once: true })
84
126
}
85
127
86
- const { data : results, status, refresh } = await useFetch (() => ` /api/run/${domain .value } ` , {
128
+ const { data : results, status, refresh } = await useAsyncData (async () => {
129
+ const [lighthouse, crux] = await Promise .all ([
130
+ $fetch (` /api/run/${domain .value } ` ),
131
+ $fetch (` /api/crux/${domain .value } ` ).catch (() => null )
132
+ ])
133
+ return { lighthouse , crux }
134
+ }, {
135
+ watch: [domain ],
87
136
immediate: !! domain .value ,
88
137
})
89
138
@@ -99,7 +148,7 @@ const favicon = computed(() => {
99
148
100
149
const value = status .value === ' pending' || (domain .value && ! results .value )
101
150
? undefined
102
- : (results .value ? results .value .performance : 100 )
151
+ : (results .value ? results .value .crux ?. cwv || results . value . lighthouse . performance : 100 )
103
152
const color = ! value ? ' #6b7280' : value >= 90 ? ' #23c55e' : value >= 50 ? ' #fbbf24' : ' #ef4444'
104
153
const svg = ` <svg xmlns="http://www.w3.org/2000/svg" height="${radius * 2 }" width="${radius * 2 }">
105
154
<style>@keyframes spin {
@@ -186,22 +235,20 @@ useServerSeoMeta({
186
235
if (! domain .value ) {
187
236
defineOgImageComponent (' Home' )
188
237
useServerSeoMeta ({
189
- description: ' See and share PageSpeed Insights results simply and easily.' ,
238
+ description: ' See and share Core Web Vitals and Page Speed Insights results simply and easily.' ,
190
239
})
191
240
} else if (results .value ) {
192
241
useServerSeoMeta ({
193
242
description:
194
- ` Performance: ${results .value ?.performance } | ` +
195
- ` Accessibility: ${results .value ?.accessibility } | ` +
196
- ` Best Practices: ${results .value ?.bestPractices } | ` +
197
- ` SEO: ${results .value ?.seo } `
243
+ ` Performance: ${results .value ?.lighthouse . performance } | ` +
244
+ ` Accessibility: ${results .value ?.lighthouse . accessibility } | ` +
245
+ ` Best Practices: ${results .value ?.lighthouse . bestPractices } | ` +
246
+ ` SEO: ${results .value ?.lighthouse . seo } `
198
247
})
199
248
200
249
defineOgImageComponent (' Lighthouse' , {
201
- performance: results .value ?.performance ,
202
- accessibility: results .value ?.accessibility ,
203
- bestPractices: results .value ?.bestPractices ,
204
- seo: results .value ?.seo ,
250
+ lighthouse: results .value .lighthouse ,
251
+ crux: results .value ?.crux ,
205
252
domain: domain .value ,
206
253
})
207
254
}
0 commit comments