Files
canina/frontend/application/lib/blogAuthor.ts
T
devops d670690816
Deploy Canina / deploy (push) Successful in 5m16s
fix(blog): unify structured author identity
2026-10-20 07:15:20 +00:00

38 lines
965 B
TypeScript

import { BLOG_TEAM_FALLBACK } from './blogDates';
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_TEAM_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: teamName, teamName };
}