@@ -21,18 +21,23 @@ public void Generate()
2121 {
2222 var flattenedNavigationItems = GetNavigationItems ( navigationItems ) ;
2323
24- var doc = new XDocument ( )
24+ var doc = new XDocument
2525 {
26- Declaration = new XDeclaration ( "1.0" , "utf-8" , "yes" ) ,
26+ Declaration = new XDeclaration ( "1.0" , "utf-8" , "yes" )
2727 } ;
2828
2929 var currentDate = DateTime . UtcNow . ToString ( "yyyy-MM-ddTHH:mm:sszzz" ) ;
3030 var root = new XElement (
3131 "urlset" ,
3232 new XAttribute ( "xlmns" , "http://www.sitemaps.org/schemas/sitemap/0.9" ) ,
3333 flattenedNavigationItems
34- . OfType < FileNavigationItem > ( )
35- . Select ( n => n . Model . Url )
34+ . Select ( n => n switch
35+ {
36+ DocumentationGroup group => ( group . Index . Url , NavigationItem : group ) ,
37+ FileNavigationItem file => ( file . Model . Url , NavigationItem : file as INavigationItem ) ,
38+ _ => throw new Exception ( $ "Unhandled navigation item type: { n . GetType ( ) } ")
39+ } )
40+ . Select ( n => n . Url )
3641 . Distinct ( )
3742 . Select ( u => new Uri ( BaseUri , u ) )
3843 . Select ( u => new XElement ( "url" , [
@@ -60,6 +65,8 @@ private static IReadOnlyCollection<INavigationItem> GetNavigationItems(IReadOnly
6065 case DocumentationGroup group :
6166 result . AddRange ( GetNavigationItems ( group . NavigationItems ) ) ;
6267 break ;
68+ default :
69+ throw new Exception ( $ "Unhandled navigation item type: { item . GetType ( ) } ") ;
6370 }
6471 }
6572 return result ;
0 commit comments