Skip to content

Commit 842aaf1

Browse files
committed
Fixed author name for blogs
1 parent 903bbf3 commit 842aaf1

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

apps/web/components/public/article.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
} from "@courselit/components-library";
1212
import { AppState } from "@courselit/state-management";
1313
import { Course, Profile, SiteInfo } from "@courselit/common-models";
14-
import { BLOG_UPDATED_PREFIX } from "@ui-config/strings";
14+
import { BLOG_UPDATED_PREFIX, UNNAMED_USER } from "@ui-config/strings";
1515

1616
interface ArticleProps {
1717
course: Course;
@@ -55,7 +55,10 @@ const Article = (props: ArticleProps) => {
5555
</div>
5656
<div className="flex flex-col gap-1">
5757
<p className="font-medium">
58-
{truncate(course.creatorName, 50)}
58+
{truncate(
59+
course.creatorName || UNNAMED_USER,
60+
50,
61+
)}
5962
</p>
6063
<p className="font-light text-sm text-muted-foreground">
6164
<span className="font-medium">

apps/web/ui-lib/utils.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,10 @@ export const sortCourseGroups = (course: Course) => {
202202
return course.groups.sort((a: Group, b: Group) => a.rank - b.rank);
203203
};
204204

205-
export function truncate(str: string, length: number) {
205+
export function truncate(str?: string, length?: number) {
206+
if (!str || !length) {
207+
return "";
208+
}
206209
return str.length <= length ? str : `${str.substring(0, length)}...`;
207210
}
208211

0 commit comments

Comments
 (0)