@@ -4,6 +4,8 @@ import WebKit
44public extension Notification . Name {
55 static let DocumentTitleDidChange = Notification . Name (
66 rawValue: " DocumentationViewControllerDocumentTitleDidChangeNotification " )
7+ static let DocumentCategoryDidChange = Notification . Name (
8+ rawValue: " DocumentationViewControllerDocumentCategoryDidChangeNotification " )
79 static let DocumentURLDidChange = Notification . Name (
810 rawValue: " DocumentationViewControllerDocumentURLDidChangeNotification " )
911 static let DocumentViewerStateDidChange = Notification . Name (
@@ -26,6 +28,11 @@ class DocumentationViewController: NSViewController {
2628 NotificationCenter . default. post ( name: . DocumentTitleDidChange, object: self )
2729 }
2830 }
31+ private( set) var documentCategory : String ? {
32+ didSet {
33+ NotificationCenter . default. post ( name: . DocumentCategoryDidChange, object: self )
34+ }
35+ }
2936 var documentURL : URL ? {
3037 didSet {
3138 NotificationCenter . default. post ( name: . DocumentURLDidChange, object: self )
@@ -149,15 +156,18 @@ class DocumentationViewController: NSViewController {
149156 }
150157
151158 private func handleTitleNotification( _ args: [ AnyHashable : Any ] ) {
152- guard let title = args [ " title " ] as! String ? else {
153- return
154- }
155- let suffix = " — DevDocs "
156- if title. hasSuffix ( suffix) {
157- self . documentTitle = title. replacingOccurrences ( of: suffix, with: " " )
158- } else {
159- self . documentTitle = title
159+ if let topic = args [ " topic " ] as! String ? {
160+ self . documentTitle = topic
161+ } else if let title = args [ " title " ] as! String ? {
162+ let suffix = " — DevDocs "
163+ if title. hasSuffix ( suffix) {
164+ self . documentTitle = title. replacingOccurrences ( of: suffix, with: " " )
165+ } else {
166+ self . documentTitle = title
167+ }
160168 }
169+
170+ self . documentCategory = args [ " doc " ] as! String ?
161171 }
162172
163173 private func handleLocationNotification( _ args: [ AnyHashable : Any ] ) {
0 commit comments