#Rendering XML
6 messages · Page 1 of 1 (latest)
what's in your composable that you can't use it in a server route or server plugin
Not much special, imho:
export const useStatamicSitemap = async (options: Options): Promise<Sitemap> => {
const { $statamic } = useNuxtApp();
if (!options.site) {
options.site = $statamic.site.handle;
}
const { data } = await useAsyncQuery<{sitemap: Sitemap}>(sitemapQuery, options);
const sitemap = data?.value?.sitemap;
if (!sitemap) {
throw new Error('Missing sitemap from Statamic.');
}
return sitemap;
};
any way to get the site handle without useNuxtApp and also use $fetch instead of useAsyncQuery ?
Not sure if I can. useAsyncQuery is the way to fetch graphql data.
useAsyncQuery is a wrapper around $fetch