const data = await useFetchWrapper(async () => {
const person = await FETCH_DOC({ endpoint: 'people', slug: params.slug as string, query: { populate: { profiles: { status: true } } } });
const id = person?.profile?.docs?.[0]?.id;
let profile = null;
if (id) {
const doc = await usePayloadFetch({ endpoint: 'profiles', query: { where: { id: { equals: id } } } });
profile = doc?.docs?.[0] || null;
}
if ((!person || !profile) && !query?.draft) await navigateTo(localePath('/'), { replace: true, redirectCode: 301 });
if (isExternalLink(profile?.externalLink)) await navigateTo(profile.externalLink, { external: true, replace: true });
return { person, profile };
});
const data = await useFetchWrapper(async () => {
const person = await FETCH_DOC({ endpoint: 'people', slug: params.slug as string, query: { populate: { profiles: { status: true } } } });
const id = person?.profile?.docs?.[0]?.id;
let profile = null;
if (id) {
const doc = await usePayloadFetch({ endpoint: 'profiles', query: { where: { id: { equals: id } } } });
profile = doc?.docs?.[0] || null;
}
if ((!person || !profile) && !query?.draft) await navigateTo(localePath('/'), { replace: true, redirectCode: 301 });
if (isExternalLink(profile?.externalLink)) await navigateTo(profile.externalLink, { external: true, replace: true });
return { person, profile };
});