@@ -28,23 +28,23 @@ public void Generate()
2828
2929 var currentDate = DateTime . UtcNow . ToString ( "yyyy-MM-ddTHH:mm:sszzz" ) ;
3030 var root = new XElement (
31- "urlset" ,
32- new XAttribute ( "xlmns" , "http://www.sitemaps.org/schemas/sitemap/0.9" ) ,
33- flattenedNavigationItems
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 )
41- . Distinct ( )
42- . Select ( u => new Uri ( BaseUri , u ) )
43- . Select ( u => new XElement ( "url" , [
44- new XElement ( "loc" , u ) ,
45- new XElement ( "lastmod" , currentDate )
46- ] ) )
47- ) ;
31+ "urlset" ,
32+ new XAttribute ( "xlmns" , "http://www.sitemaps.org/schemas/sitemap/0.9" ) ,
33+ flattenedNavigationItems
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 )
41+ . Distinct ( )
42+ . Select ( u => new Uri ( BaseUri , u ) )
43+ . Select ( u => new XElement ( "url" , [
44+ new XElement ( "loc" , u ) ,
45+ new XElement ( "lastmod" , currentDate )
46+ ] ) )
47+ ) ;
4848
4949 doc . Add ( root ) ;
5050
@@ -57,6 +57,9 @@ private static IReadOnlyCollection<INavigationItem> GetNavigationItems(IReadOnly
5757 var result = new List < INavigationItem > ( ) ;
5858 foreach ( var item in items )
5959 {
60+ if ( item . Hidden )
61+ continue ;
62+
6063 switch ( item )
6164 {
6265 case FileNavigationItem file :
@@ -70,6 +73,7 @@ private static IReadOnlyCollection<INavigationItem> GetNavigationItems(IReadOnly
7073 throw new Exception ( $ "Unhandled navigation item type: { item . GetType ( ) } ") ;
7174 }
7275 }
76+
7377 return result ;
7478 }
7579}
0 commit comments