Files
canina/frontend/application/lib/blogAuthor.ts
T
devops 44d74d35e6
Deploy Canina / deploy (push) Successful in 4m50s
fix(blog): publish truthful image and team SEO metadata
2026-10-25 18:03:49 +00:00

43 lines
1.3 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) {
// Specialty accounts identify themselves as a team, not a named individual.
// An individual's authorTeam affiliation alone does not change their type.
const isTeamAccount = /(?:^|\s)تیم(?:\s|$)/u.test(personName);
return { type: isTeamAccount ? 'Organization' : 'Person', name: personName, teamName };
}
return { type: 'Organization', name: BLOG_AUTHOR_FALLBACK, teamName };
}