Skip to content

Commit 3bf432e

Browse files
committed
refactor
1 parent 36c3b10 commit 3bf432e

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

middleware/contextualizers/early-access-links.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,14 @@ module.exports = function earlyAccessContext (req, res, next) {
77

88
// Get a list of all hidden pages per version
99
const earlyAccessPageLinks = uniq(Object.values(req.context.pages)
10-
.filter(page => page.hidden)
11-
// Do not include early access landing page
12-
.filter(page => page.relativePath !== 'early-access/index.md')
13-
// Create Markdown links
14-
.map(page => {
15-
return page.permalinks.map(permalink => `- [${permalink.title}](${permalink.href})`)
16-
})
10+
.filter(page => page.hidden && page.relativePath.startsWith('early-access') && page.relativePath !== 'early-access/index.md')
11+
.map(page => page.permalinks)
1712
.flat())
1813
// Get links for the current version
19-
.filter(link => link.includes(req.context.currentVersion))
14+
.filter(permalink => req.context.currentVersion === permalink.pageVersion)
2015
.sort()
16+
// Create Markdown links
17+
.map(permalink => `- [${permalink.title}](${permalink.href})`)
2118

2219
// Add to the rendering context
2320
// This is only used in the separate EA repo on local development

0 commit comments

Comments
 (0)