fix: add missing readBooks translations
Some checks failed
Dev Deployment (Zero Downtime) / deploy-dev (push) Has been cancelled

This commit is contained in:
2026-02-16 00:37:34 +01:00
parent 0a0895cf89
commit 931843a5c6
21 changed files with 945 additions and 16 deletions

View File

@@ -453,8 +453,11 @@ export async function getBookReviews(locale: string): Promise<BookReview[] | nul
book_image
rating
finished_at
translations(filter: { languages_code: { code: { _eq: "${directusLocale}" } } }) {
translations {
review
languages_code {
code
}
}
}
}
@@ -471,16 +474,23 @@ export async function getBookReviews(locale: string): Promise<BookReview[] | nul
return null;
}
return reviews.map((item: any) => ({
id: item.id,
hardcover_id: item.hardcover_id || undefined,
book_title: item.book_title,
book_author: item.book_author,
book_image: item.book_image || undefined,
rating: typeof item.rating === 'number' ? item.rating : parseInt(item.rating) || 0,
review: item.translations?.[0]?.review || undefined,
finished_at: item.finished_at || undefined,
}));
return reviews.map((item: any) => {
// Filter die passende Übersetzung im Code
const translation = item.translations?.find(
(t: any) => t.languages_code?.code === directusLocale
) || item.translations?.[0]; // Fallback auf die erste Übersetzung falls locale nicht passt
return {
id: item.id,
hardcover_id: item.hardcover_id || undefined,
book_title: item.book_title,
book_author: item.book_author,
book_image: item.book_image || undefined,
rating: typeof item.rating === 'number' ? item.rating : parseInt(item.rating) || 0,
review: translation?.review || undefined,
finished_at: item.finished_at || undefined,
};
});
} catch (error) {
console.error(`Failed to fetch book reviews (${locale}):`, error);
return null;
@@ -503,6 +513,8 @@ export interface Project {
future_improvements?: string;
github_url?: string;
live_url?: string;
button_live_label?: string;
button_github_label?: string;
image_url?: string;
demo_video_url?: string;
performance_metrics?: string;
@@ -592,6 +604,8 @@ export async function getProjects(
content
meta_description
keywords
button_live_label
button_github_label
languages_code { code }
}
}
@@ -644,6 +658,8 @@ export async function getProjects(
future_improvements: proj.future_improvements,
github_url: proj.github,
live_url: proj.live,
button_live_label: trans.button_live_label,
button_github_label: trans.button_github_label,
image_url: proj.image_url,
demo_video_url: proj.demo_video,
performance_metrics: proj.performance_metrics,
@@ -703,6 +719,8 @@ export async function getProjectBySlug(
content
meta_description
keywords
button_live_label
button_github_label
languages_code { code }
}
}
@@ -755,6 +773,8 @@ export async function getProjectBySlug(
future_improvements: proj.future_improvements,
github_url: proj.github,
live_url: proj.live,
button_live_label: trans.button_live_label,
button_github_label: trans.button_github_label,
image_url: proj.image_url,
demo_video_url: proj.demo_video,
screenshots: parseTags(proj.screenshots),