File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -122,4 +122,55 @@ describe('getCustomMenu', () => {
122122
123123 expect ( menus [ 0 ] . href ) . toBe ( '/guide' )
124124 } )
125+
126+ it ( 'uses the generated href when a menu explicitly targets an invisible page' , ( ) => {
127+ const collectionData = [
128+ {
129+ id : 'page-pending' ,
130+ type : 'Page' ,
131+ status : 'Invisible' ,
132+ slug : 'pending'
133+ } ,
134+ {
135+ id : 'menu-pending' ,
136+ type : 'Menu' ,
137+ status : 'Published' ,
138+ title : 'Pending' ,
139+ slug : 'pending' ,
140+ href : '/pending'
141+ }
142+ ]
143+ const sourcePageSlugs = getSourcePageSlugs ( collectionData )
144+ collectionData [ 0 ] . slug = 'pending/2026/07/29/pending'
145+ collectionData [ 0 ] . href = '/pending/2026/07/29/pending'
146+
147+ const menus = getCustomMenu ( { collectionData, sourcePageSlugs } )
148+
149+ expect ( menus [ 0 ] . href ) . toBe ( '/pending/2026/07/29/pending' )
150+ } )
151+
152+ it ( 'does not expose an unpublished page through a matching menu slug' , ( ) => {
153+ const collectionData = [
154+ {
155+ id : 'page-draft' ,
156+ type : 'Page' ,
157+ status : 'Draft' ,
158+ slug : 'draft' ,
159+ href : '/manual/draft'
160+ } ,
161+ {
162+ id : 'menu-draft' ,
163+ type : 'Menu' ,
164+ status : 'Published' ,
165+ title : 'Draft' ,
166+ slug : 'draft' ,
167+ href : '/draft'
168+ }
169+ ]
170+ const sourcePageSlugs = getSourcePageSlugs ( collectionData )
171+
172+ const menus = getCustomMenu ( { collectionData, sourcePageSlugs } )
173+
174+ expect ( menus [ 0 ] . href ) . toBe ( '/draft' )
175+ } )
125176} )
Original file line number Diff line number Diff line change @@ -28,7 +28,9 @@ function getPageHrefBySourceSlug(collectionData, sourcePageSlugs) {
2828 const ambiguousSlugs = new Set ( )
2929
3030 collectionData . forEach ( page => {
31- if ( page ?. type !== 'Page' || page ?. status !== 'Published' || ! page ?. href ) {
31+ const isDirectlyRoutable =
32+ page ?. status === 'Published' || page ?. status === 'Invisible'
33+ if ( page ?. type !== 'Page' || ! isDirectlyRoutable || ! page ?. href ) {
3234 return
3335 }
3436
You can’t perform that action at this time.
0 commit comments