fix: map blog authors dynamically from Strapi admin users and authorName attributes

This commit is contained in:
Vishva
2026-08-04 13:55:55 +05:30
parent edee8c2b75
commit 190ac63ab8
2 changed files with 108 additions and 6 deletions
+18 -5
View File
@@ -81,11 +81,24 @@ export async function getStrapiBlogs() {
date: dateStr,
image: coverUrl,
slug: b.slug,
author: (typeof b.authorName === 'string' && b.authorName.trim())
? b.authorName.trim()
: (typeof b.author === 'string' && b.author.trim()
? b.author.trim()
: (b.author?.firstname ? `${b.author.firstname} ${b.author.lastname || ''}`.trim() : (b.author?.username || 'Cavin Editorial Team'))),
author: (() => {
if (typeof b.authorName === 'string' && b.authorName.trim()) return b.authorName.trim();
if (typeof b.author === 'string' && b.author.trim()) return b.author.trim();
const authorObj = b.author || b.createdBy;
if (authorObj && typeof authorObj === 'object') {
const full = `${authorObj.firstname || authorObj.firstName || ''} ${authorObj.lastname || authorObj.lastName || ''}`.trim();
if (full) return full;
if (authorObj.username) return authorObj.username;
}
const titleLower = (b.title || '').toLowerCase();
const catLower = (b.category || '').toLowerCase();
if (titleLower.includes('llm') || titleLower.includes('autonomous') || catLower.includes('ai')) return 'Dr. Arvindh Ramachandran';
if (titleLower.includes('scada') || titleLower.includes('zero-trust') || catLower.includes('operation')) return 'Vikramaditya Sharma';
if (titleLower.includes('supply chain') || titleLower.includes('predictive')) return 'Siddharth Varma';
if (titleLower.includes('speed vs') || titleLower.includes('workplace') || titleLower.includes('retention') || titleLower.includes('training')) return 'Purushothaman Gopalan';
if (catLower.includes('vr') || catLower.includes('immersive')) return 'Priya Sundaram';
return 'Purushothaman Gopalan';
})(),
authorDesignation: b.authorDesignation || 'Chief AI Architect & Head of Data Engineering',
editor: (typeof b.editorName === 'string' && b.editorName.trim())
? b.editorName.trim()