diff --git a/lib/directus.ts b/lib/directus.ts index de55d87..7abe337 100644 --- a/lib/directus.ts +++ b/lib/directus.ts @@ -549,6 +549,21 @@ export async function getProjects( proj.translations?.find((t: any) => t.languages_code?.code === directusLocale) || proj.translations?.[0] || {}; + + // Parse JSON string fields if needed + const parseTags = (tags: any) => { + if (!tags) return []; + if (Array.isArray(tags)) return tags; + if (typeof tags === 'string') { + try { + return JSON.parse(tags); + } catch { + return []; + } + } + return []; + }; + return { id: proj.id, slug: proj.slug, @@ -557,8 +572,8 @@ export async function getProjects( content: trans.content, category: proj.category, difficulty: proj.difficulty, - tags: proj.tags || [], - technologies: proj.technologies || [], + tags: parseTags(proj.tags), + technologies: parseTags(proj.technologies), challenges: proj.challenges, lessons_learned: proj.lessons_learned, future_improvements: proj.future_improvements, @@ -567,7 +582,7 @@ export async function getProjects( image_url: proj.image_url, demo_video_url: proj.demo_video, performance_metrics: proj.performance_metrics, - screenshots: proj.screenshots || [], + screenshots: parseTags(proj.screenshots), featured: proj.featured === 1 || proj.featured === true, published: proj.status === 'published', created_at: proj.date_created,