diff --git a/app.vue b/app.vue index d232008..bb1fe64 100644 --- a/app.vue +++ b/app.vue @@ -14,16 +14,52 @@ @@ -83,7 +125,14 @@ function enableEditing () { }, { once: true }) } -const { data: results, status, refresh } = await useFetch(() => `/api/run/${domain.value}`, { +const { data: results, status, refresh } = await useAsyncData(async () => { + const [lighthouse, crux] = await Promise.all([ + $fetch(`/api/run/${domain.value}`), + $fetch(`/api/crux/${domain.value}`).catch(() => null) + ]) + return { lighthouse, crux } +}, { + watch: [domain], immediate: !!domain.value, }) @@ -99,7 +148,7 @@ const favicon = computed(() => { const value = status.value === 'pending' || (domain.value && !results.value) ? undefined - : (results.value ? results.value.performance : 100) + : (results.value ? results.value.crux?.cwv || results.value.lighthouse.performance : 100) const color = !value ? '#6b7280' : value >= 90 ? '#23c55e' : value >= 50 ? '#fbbf24' : '#ef4444' const svg = ` + + + + + + + {{ value?.caption.replace(/m?s/, '') }} + {{ value?.caption?.match(/m?s/)![0] }} + + + + {{ caption }} + + + diff --git a/components/OgImage/Lighthouse.vue b/components/OgImage/Lighthouse.vue index 10468fa..d9f4e95 100644 --- a/components/OgImage/Lighthouse.vue +++ b/components/OgImage/Lighthouse.vue @@ -4,21 +4,12 @@ defineProps({ type: String, required: true, }, - performance: { - type: Number, - required: true, - }, - accessibility: { - type: Number, - required: true, + lighthouse: { + type: Object, + required: true }, - bestPractices: { - type: Number, - required: true, - }, - seo: { - type: Number, - required: true, + crux: { + type: Object }, }) @@ -26,13 +17,46 @@ defineProps({