@@ -10,8 +10,8 @@ const findPageInVersion = require('../../lib/find-page-in-version')
1010const rest = require ( '../../middleware/contextualizers/rest' )
1111const graphql = require ( '../../middleware/contextualizers/graphql' )
1212const contextualize = require ( '../../middleware/context' )
13- // TODO enable when release notes are live
14- // const releaseNotes = require('../../middleware/contextualizers/enterprise-release-notes ')
13+ const releaseNotes = require ( '../../middleware/contextualizers/enterprise- release- notes' )
14+ const versionSatisfiesRange = require ( '../../lib/version-satisfies-range ' )
1515
1616class LinksChecker {
1717 constructor ( opts = { languageCode : 'en' , internalHrefPrefixes : [ '/' , '#' ] } ) {
@@ -225,26 +225,35 @@ async function buildInitialContext () {
225225 return req . context
226226}
227227
228- async function buildPathContext ( context , page , permalink ) {
228+ async function buildPathContext ( initialContext , page , permalink ) {
229+ // Create a new object with path-specific properties
229230 const pathContext = {
230231 page,
231232 currentVersion : permalink . pageVersion ,
232233 relativePath : permalink . relativePath
233234 }
234235
236+ // Combine it with the initial context object that has pages, redirects, etc.
237+ const combinedContext = Object . assign ( { } , initialContext , pathContext )
238+
239+ // Create a new req object using the combined context
235240 const req = {
236241 path : permalink . href ,
237- context : Object . assign ( { } , context , pathContext ) ,
242+ context : combinedContext ,
238243 language : 'en' ,
239244 query : { }
240245 }
241246
247+ // Pass the req to the contextualizing middlewares
242248 await applyMiddleware ( rest , req )
243249 await applyMiddleware ( graphql , req )
244- // TODO enable when release notes are live
245- // await applyMiddleware(releaseNotes, req)
250+ // Release notes are on docs site starting with GHES 3.0
251+ if ( versionSatisfiesRange ( permalink . pageVersion , '>=3.0' ) ) {
252+ await applyMiddleware ( releaseNotes , req )
253+ }
246254
247- return Object . assign ( { } , context , req . context )
255+ // Return the resulting context object with REST, GraphQL, and release notes data now attached
256+ return req . context
248257}
249258
250259module . exports = {
0 commit comments