Skip to content

Commit

Permalink
Default to empty author
Browse files Browse the repository at this point in the history
  • Loading branch information
wjglerum committed Dec 15, 2023
1 parent 86a0739 commit 017c86e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/models/Post.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ case class Post(slug: String, mainImage: String, content: String, author: Option
content,
Options.builder().build())

lazy val authorName: String = document.getAuthors.asScala.headOption.map(_.getFullName)
lazy val authorName: String = document.getAuthors.asScala.headOption.map(_.getFullName).getOrElse("")

lazy val authorsNames: Seq[String] = document.getAuthors.asScala.map(_.getFullName).toSeq

Expand All @@ -49,7 +49,7 @@ case class Post(slug: String, mainImage: String, content: String, author: Option
"slug" -> JsString(slug),
"lang" -> JsString(lang),
"image_url" -> JsString(mainImage),
"author" -> JsString(author.map(_.name.getOrElse(authorName)).getOrElse(authorName)),
"author" -> JsString(author.flatMap(_.name).getOrElse(authorName)),
"authors" -> JsArray(authorsNames.map(JsString)),
"author_name" -> JsString(authorName),
"author_img" -> JsString(author.map(_.avatar_url).getOrElse("null")),
Expand Down

0 comments on commit 017c86e

Please sign in to comment.