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