ff-webpage/app/plugins/sitemap.ts

34 lines
828 B
TypeScript
Raw Permalink Normal View History

2025-07-23 13:46:18 +02:00
import type Page from "~~/types/collection/page";
import type Global from "~~/types/single/global";
2025-05-10 17:37:58 +02:00
export default defineNuxtPlugin(async (nuxtApp) => {
const pageState = useState<Page[]>("sitemap_pages", () => []);
2025-07-23 13:46:18 +02:00
if (pageState.value.length == 0) {
2025-05-10 17:37:58 +02:00
const { find } = useStrapi();
const { data: page_res } = await useAsyncData(
"sitemap_pages",
() =>
find<Page>("pages", {
filters: {
2025-07-23 13:46:18 +02:00
//@ts-ignore
$or: [
{
ref_only_access: { $eq: false },
},
{
ref_only_access: { $null: true },
},
],
2025-05-10 17:37:58 +02:00
},
}),
{
server: true,
lazy: false,
default: () => {},
}
);
pageState.value = page_res.value?.data ?? [];
}
});