@@ -43,7 +43,7 @@ case class DefaultParams(
43
43
" root" -> site.root
44
44
).asJava,
45
45
46
- " sidebar" -> sidebar.titles.asJava
46
+ " sidebar" -> sidebar.toMap
47
47
)
48
48
val entityMap = entity match {
49
49
case NonEntity => Map .empty
@@ -79,7 +79,11 @@ case class SiteInfo(
79
79
root : String
80
80
)
81
81
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
+ }
83
87
84
88
object Sidebar {
85
89
def apply (map : HashMap [String , AnyRef ]): Option [Sidebar ] = Option (map.get(" sidebar" )).map {
@@ -91,7 +95,15 @@ object Sidebar {
91
95
def empty : Sidebar = Sidebar (Nil )
92
96
}
93
97
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
+ }
95
107
96
108
object Title {
97
109
def apply (map : JMap [String , AnyRef ]): Option [Title ] = {
@@ -101,13 +113,18 @@ object Title {
101
113
val url = Option (map.get(" url" )).collect {
102
114
case s : String => s
103
115
}
116
+
117
+ val description = Option (map.get(" description" )).collect {
118
+ case s : String => s
119
+ }
120
+
104
121
val subsection = Option (map.get(" subsection" )).collect {
105
122
case xs : JList [JMap [String , AnyRef ]] @ unchecked =>
106
123
xs.asScala.map(Title .apply).toList.flatMap(x => x)
107
124
}.getOrElse(Nil )
108
125
109
126
title.map {
110
- case title : String => Title (title, url, subsection)
127
+ case title : String => Title (title, url, subsection, description )
111
128
}
112
129
}
113
130
}
0 commit comments