@@ -41,6 +41,7 @@ import { uploadArtifact } from '@/links/scripts/upload-artifact'
4141import { createReportIssue , linkReports } from '@/workflows/issue-report'
4242import github from '@/workflows/github'
4343import excludedLinks from '@/links/lib/excluded-links'
44+ import { getFeaturesByVersion } from '@/versions/middleware/features'
4445import type { Page , Permalink , Context } from '@/types'
4546import * as coreLib from '@actions/core'
4647
@@ -171,25 +172,30 @@ async function checkVersion(
171172
172173 console . log ( ` Checking ${ relevantPages . length } pages for ${ version } /${ language } ` )
173174
175+ // Build a base context once per version — feature flags and version info are the same for all pages
176+ const baseContext : Context = {
177+ currentVersion : version ,
178+ currentLanguage : language ,
179+ currentVersionObj : versionObj ,
180+ [ versionObj . shortName ] : true ,
181+ pages : pageMap ,
182+ redirects,
183+ ...getFeaturesByVersion ( version ) ,
184+ } as Context
185+
174186 for ( const page of relevantPages ) {
175187 // Find the permalink for this version
176188 const permalink = page . permalinks ?. find ( ( p ) => p . pageVersion === version )
177189 if ( ! permalink ) continue
178190
179191 totalPagesChecked ++
180192
181- // Create context for rendering
182- const context : Context = {
183- currentVersion : version ,
184- currentLanguage : language ,
185- currentVersionObj : versionObj ,
186- page,
187- pages : pageMap ,
188- redirects,
189- } as Context
193+ // Mutate the page property in place — safe because the loop is sequential (each iteration
194+ // awaits before the next begins), so there is no concurrent access to baseContext.
195+ baseContext . page = page
190196
191197 // Get links from rendered page
192- const links = await getLinksFromRenderedPage ( page , permalink , context )
198+ const links = await getLinksFromRenderedPage ( page , permalink , baseContext )
193199 totalLinksChecked += links . length
194200
195201 // Check each link
@@ -233,7 +239,7 @@ async function checkVersion(
233239
234240 // Check anchors if enabled
235241 if ( options . checkAnchors ) {
236- const anchorFlaws = await checkAnchorsOnPage ( page , permalink , context )
242+ const anchorFlaws = await checkAnchorsOnPage ( page , permalink , baseContext )
237243 brokenLinks . push ( ...anchorFlaws )
238244 }
239245
0 commit comments