forked from github/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshort-versions.js
More file actions
23 lines (20 loc) · 788 Bytes
/
short-versions.js
File metadata and controls
23 lines (20 loc) · 788 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// This module creates shortcuts for version comparisons in Liquid conditional strings.
//
// Supported:
// {% if fpt %}
// {% if ghae %}
// {% if ghes %}
//
// For the custom operator handling in statements like {% if ghes > 3.0 %}, see `lib/liquid-tags/if-ver.js`.
export default function shortVersions(req, res, next) {
const { allVersions, currentVersion } = req.context
const currentVersionObj = allVersions[currentVersion]
if (!currentVersionObj) return next()
// Add the short name to context.
req.context[currentVersionObj.shortName] = true
// Add convenience props.
req.context.currentVersionObj = currentVersionObj
req.context.currentRelease = currentVersion.split('@')[1]
req.context.currentVersionShortName = currentVersionObj.shortName
return next()
}