From 690a21cc19e29fd0853fced44a0e7a25530dfb25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Svebor=20Sori=C4=87?= <74537302+Sveb@users.noreply.github.com> Date: Fri, 3 Oct 2025 15:27:09 +0200 Subject: [PATCH 1/4] Adjusts the way wp-seo fetches data - testing --- app/components/wp-seo.vue | 36 +++++++++++++++++++++++------------- app/layouts/default.vue | 2 +- app/pages/shop.vue | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 14 deletions(-) create mode 100644 app/pages/shop.vue diff --git a/app/components/wp-seo.vue b/app/components/wp-seo.vue index af8f96d..25de4f8 100644 --- a/app/components/wp-seo.vue +++ b/app/components/wp-seo.vue @@ -33,26 +33,36 @@ const props = defineProps({ imageUrl: { type: String, default: '' + }, + fetchData: { + type: Boolean, + default: true } }) // Fetch data from WP const parsedPath = computed(() => props.path || route.path || '') +const data = ref({}) // Fetch data from WP -const { data, error } = await useWpFetch(`/post`, { - query: { - uri: parsedPath - }, - pick: ['title', 'excerpt', 'content', 'featuredMedia'], - onResponseError() { - console.warn(' Fetch Error:', parsedPath.value) - } -}) - -// On error, set data to empty object -if (error.value) { - data.value = {} +if (props.fetchData) { + console.log('fetching data') + const { data: fetchedData, error } = await useWpFetch(`/post`, { + onResponse() { + data.value = fetchedData.value + }, + query: { + uri: parsedPath + }, + pick: ['title', 'excerpt', 'content', 'featuredMedia'], + onResponseError() { + console.warn(' Fetch Error:', parsedPath.value, error) + } + }) + console.log('data', data.value) +} +else { + console.log('not fetching data') } // Computeds diff --git a/app/layouts/default.vue b/app/layouts/default.vue index 64ec28a..7a4e2c1 100644 --- a/app/layouts/default.vue +++ b/app/layouts/default.vue @@ -1,6 +1,6 @@