chore: enhance home page robustness and finalized database unification
This commit is contained in:
parent
949811297a
commit
0ab9cf1c16
@ -10,16 +10,21 @@ async function fetchHomeData() {
|
|||||||
try {
|
try {
|
||||||
const client = await createAdminClient();
|
const client = await createAdminClient();
|
||||||
|
|
||||||
// 1. Settings
|
// 1. Settings with fallback
|
||||||
const settingsRes = await client.databases.listDocuments(APPWRITE_ALMEIRA_CONFIG.databaseId, 'settings', []);
|
let settings: any = {};
|
||||||
const settings: any = settingsRes.documents.length > 0 ? settingsRes.documents[0] : {};
|
try {
|
||||||
|
const settingsRes = await client.databases.listDocuments(APPWRITE_ALMEIRA_CONFIG.databaseId, 'settings', [Query.limit(1)]);
|
||||||
|
settings = settingsRes.documents.length > 0 ? settingsRes.documents[0] : {};
|
||||||
|
} catch (e) {
|
||||||
|
console.error("Settings fetch error", e);
|
||||||
|
}
|
||||||
|
|
||||||
const postsCount = settings.feed_news_count || 12;
|
const postsCount = settings?.feed_news_count || 12;
|
||||||
const cardSettings = {
|
const cardSettings = {
|
||||||
showCategory: settings.news_card_show_category ?? false,
|
showCategory: settings?.news_card_show_category ?? false,
|
||||||
showFooterDate: settings.show_news_date ?? false,
|
showFooterDate: settings?.show_news_date ?? true,
|
||||||
showFooterButton: settings.news_card_show_footer_button ?? true,
|
showFooterButton: settings?.news_card_show_footer_button ?? true,
|
||||||
footerText: settings.news_card_footer_text || ""
|
footerText: settings?.news_card_footer_text || ""
|
||||||
};
|
};
|
||||||
|
|
||||||
// 2. Get NOTICIA type ID
|
// 2. Get NOTICIA type ID
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user