@@ -43,7 +43,7 @@ case class DefaultParams(
4343 " root" -> site.root
4444 ).asJava,
4545
46- " sidebar" -> sidebar.titles.asJava
46+ " sidebar" -> sidebar.toMap
4747 )
4848 val entityMap = entity match {
4949 case NonEntity => Map .empty
@@ -79,7 +79,11 @@ case class SiteInfo(
7979 root : String
8080)
8181
82- case class Sidebar (titles : List [Title ])
82+ case class Sidebar (titles : List [Title ]) {
83+ import model .JavaConverters ._
84+ def toMap : JMap [String , _] =
85+ Map (" titles" -> titles.map(_.toMap).asJava).asJava
86+ }
8387
8488object Sidebar {
8589 def apply (map : HashMap [String , AnyRef ]): Option [Sidebar ] = Option (map.get(" sidebar" )).map {
@@ -91,7 +95,15 @@ object Sidebar {
9195 def empty : Sidebar = Sidebar (Nil )
9296}
9397
94- case class Title (title : String , url : Option [String ], subsection : List [Title ])
98+ case class Title (title : String , url : Option [String ], subsection : List [Title ], description : Option [String ]) {
99+ import model .JavaConverters ._
100+ def toMap : JMap [String , _] = Map (
101+ " title" -> title,
102+ " url" -> url.getOrElse(null ), // ugh, Java
103+ " subsection" -> subsection.map(_.toMap).asJava,
104+ " description" -> description.getOrElse(null )
105+ ).asJava
106+ }
95107
96108object Title {
97109 def apply (map : JMap [String , AnyRef ]): Option [Title ] = {
@@ -101,13 +113,18 @@ object Title {
101113 val url = Option (map.get(" url" )).collect {
102114 case s : String => s
103115 }
116+
117+ val description = Option (map.get(" description" )).collect {
118+ case s : String => s
119+ }
120+
104121 val subsection = Option (map.get(" subsection" )).collect {
105122 case xs : JList [JMap [String , AnyRef ]] @ unchecked =>
106123 xs.asScala.map(Title .apply).toList.flatMap(x => x)
107124 }.getOrElse(Nil )
108125
109126 title.map {
110- case title : String => Title (title, url, subsection)
127+ case title : String => Title (title, url, subsection, description )
111128 }
112129 }
113130}
0 commit comments