Skip to content

Commit 3f7c59c

Browse files
committed
Handle anonymous author
1 parent 81ed54c commit 3f7c59c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pkg/posts/post.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,13 @@ func openPost(app *tview.Application, postcuid string, list *tview.List) {
3535
})
3636

3737
title := fmt.Sprintf("Title: %s", singlePost.Post.Title)
38-
author := fmt.Sprintf("Author: %s", singlePost.Post.Author.Name)
38+
var author string
39+
if singlePost.Post.Author.Name != "" {
40+
author = fmt.Sprintf("Author: %s", singlePost.Post.Author.Name)
41+
} else {
42+
author = fmt.Sprintf("Author: Anonymous")
43+
}
44+
3945
reactions := fmt.Sprintf("Reactions: %d", singlePost.Post.TotalReactions)
4046
ptype := fmt.Sprintf("Type: %s", singlePost.Post.Type)
4147
link := fmt.Sprintf("Link: https://hashnode.com/post/%s", singlePost.Post.Cuid)

0 commit comments

Comments
 (0)