Jelmer
Jelmer
NNuxt
Created by Jelmer on 3/28/2024 in #❓・help
Rendering XML
I did not know that, thanks! I will try that.
4 replies
NNuxt
Created by Jelmer on 3/28/2024 in #❓・help
Rendering XML
Not sure if I can. useAsyncQuery is the way to fetch graphql data.
4 replies
NNuxt
Created by Jelmer on 3/28/2024 in #❓・help
Rendering XML
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;
};
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;
};
4 replies