Files
canina/frontend/application/lib/blogAuthor.ts
T
devops 159e4a4cbf
Deploy Canina / deploy (push) Successful in 2m47s
fix(blog): separate Canina author and editorial team
2026-10-20 07:52:07 +00:00

40 lines
1.0 KiB
TypeScript

import { BLOG_TEAM_FALLBACK } from './blogDates';
export const BLOG_AUTHOR_FALLBACK = 'کنینا';
type BlogAuthor = {
firstName?: string | null;
lastName?: string | null;
};
interface BlogAuthorInput {
author?: BlogAuthor | null;
authorTeam?: string | null;
}
export interface ResolvedBlogAuthor {
type: 'Person' | 'Organization';
name: string;
teamName: string;
}
export function resolveBlogAuthor(author?: BlogAuthor | null): string {
const name = author
? `${author.firstName || ''} ${author.lastName || ''}`.trim()
: '';
return name || BLOG_AUTHOR_FALLBACK;
}
export function resolveBlogAuthorIdentity(blog: BlogAuthorInput): ResolvedBlogAuthor {
const personName = blog.author
? `${blog.author.firstName || ''} ${blog.author.lastName || ''}`.trim()
: '';
const teamName = blog.authorTeam?.trim() || BLOG_TEAM_FALLBACK;
if (personName) {
return { type: 'Person', name: personName, teamName };
}
return { type: 'Organization', name: BLOG_AUTHOR_FALLBACK, teamName };
}