feat: fill pages
All checks were successful
Publish Docker Images / build-and-publish (push) Successful in 10m25s

This commit is contained in:
2025-11-11 19:12:21 +01:00
parent 3f828a754b
commit fceeb5307c
38 changed files with 634 additions and 65 deletions

View File

@@ -0,0 +1,33 @@
import { withLeadingSlash } from 'ufo';
import type { Collections } from '@nuxt/content';
export const useDataJson = (prefix: string) => {
const route = useRoute();
const { locale } = useI18n();
const slug = computed(() => {
// Use route.params.slug for dynamic routes, or route.path for static routes
const slugValue = route.params.slug || route.path;
return withLeadingSlash(String(slugValue));
});
const key = computed(() => prefix + '-' + slug.value);
const getJsonData = async (collectionPrefix: string = 'content_data_') => {
const { data } = await useAsyncData(key.value, async () => {
const collection = (collectionPrefix + locale.value) as keyof Collections;
const allData = await queryCollection(collection).all();
const filtered = allData.filter((source) => source.meta.path == slug.value)[0];
return filtered?.meta;
}, {
watch: [locale], // Automatically refresh when locale changes
});
return data;
};
const getCachedData = () => {
const { data } = useNuxtData(key.value);
return data;
};
return { getJsonData, getCachedData };
};