File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed
Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ import {
1111} from "@courselit/components-library" ;
1212import { AppState } from "@courselit/state-management" ;
1313import { 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
1616interface 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" >
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments