MCPcopy
hub / github.com/github/docs / ghaeReleaseNotesContext

Function ghaeReleaseNotesContext

middleware/contextualizers/ghae-release-notes.js:5–39  ·  view source on GitHub ↗
(req, res, next)

Source from the content-addressed store, hash-verified

3import { getReleaseNotes } from './get-release-notes.js'
4
5export default async function ghaeReleaseNotesContext(req, res, next) {
6 if (!(req.pagePath.endsWith('/release-notes') || req.pagePath.endsWith('/admin'))) return next()
7 if (
8 !allVersions[req.context.currentVersion] ||
9 req.context.currentVersion.split('@')[0] !== 'github-ae'
10 )
11 return next()
12
13 const ghaeReleaseNotes = getReleaseNotes('github-ae', req.language)
14
15 // internalLatestRelease is set in lib/all-versions, e.g., '3.5' but UI still displays '@latest'.
16 let requestedRelease = req.context.currentVersionObj.internalLatestRelease
17
18 // The internalLatestRelease may not necessarily correspond to an existing release notes number,
19 // so just fall back to the latest existing release note number.
20 if (!Object.keys(ghaeReleaseNotes).includes(requestedRelease.replace(/\./, '-'))) {
21 requestedRelease = Object.keys(ghaeReleaseNotes)[0].replace(/-/, '.')
22 }
23
24 // Returns [{version, patches: [ {version, patchVersion, intro, date, sections: { features: [], bugs: []...}} ] }]
25 req.context.ghaeReleases = formatReleases(ghaeReleaseNotes)
26
27 // Run _all_ the GHAE patches through the markdown rendering pipeline.
28 // This is different from req.context.ghesReleaseNotes, which renders one release at a time.
29 // Returns all patches: [{version, patchVersion, intro, date, sections}]
30 req.context.ghaeReleaseNotes = (
31 await Promise.all(
32 req.context.ghaeReleases.map(
33 async (release) => await renderPatchNotes(release.patches, req.context)
34 )
35 )
36 ).flat()
37
38 return next()
39}

Callers

nothing calls this directly

Calls 4

getReleaseNotesFunction · 0.90
formatReleasesFunction · 0.90
renderPatchNotesFunction · 0.90
nextFunction · 0.50

Tested by

no test coverage detected