fix: restore getMessage compatibility and finalize build

This commit is contained in:
2026-02-16 01:13:07 +01:00
parent b6eb24f2e8
commit f5081f8765

View File

@@ -121,6 +121,36 @@ export async function getMessages(locale: string): Promise<Record<string, string
} }
} }
/**
* Get a single message by key from Directus
*/
export async function getMessage(key: string, locale: string): Promise<string | null> {
const directusLocale = toDirectusLocale(locale);
const query = `
query {
messages(filter: {key: {_eq: "${key}"}}, limit: 1) {
key
translations {
value
languages_code { code }
}
}
}
`;
try {
const result = await directusRequest('', { body: { query } });
const messages = (result as any)?.messages;
if (!messages || messages.length === 0) return null;
const translations = messages[0]?.translations || [];
const translation = translations.find((t: any) => t.languages_code?.code === directusLocale);
return translation?.value || null;
} catch (error) {
return null;
}
}
export async function getContentPage( export async function getContentPage(
slug: string, slug: string,
locale: string locale: string