ff-webpage/plugins/global.ts

15 lines
464 B
TypeScript

import type Global from "../types/single/global";
export default defineNuxtPlugin(async (nuxtApp) => {
const globalState = useState<Global | null>("global", () => null);
if (!globalState.value) {
const { findOne } = useStrapi();
const { data: global } = await useAsyncData("global", () => findOne<Global>("global"), {
server: true,
lazy: false,
default: () => {},
});
globalState.value = global.value?.data ?? null;
}
});