-
Notifications
You must be signed in to change notification settings - Fork 66.8k
Expand file tree
/
Copy pathengine.js
More file actions
54 lines (46 loc) · 1.34 KB
/
engine.js
File metadata and controls
54 lines (46 loc) · 1.34 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { Liquid } from 'liquidjs'
import GithubSlugger from 'github-slugger'
import IndentedDataReference from './indented-data-reference'
import Data from './data'
import Octicon from './octicon'
import Ifversion from './ifversion'
import { Tool, tags as toolTags } from './tool'
import { Spotlight, tags as spotlightTags } from './spotlight'
import { Prompt } from './prompt'
export const engine = new Liquid({
extname: '.html',
dynamicPartials: false,
})
engine.registerTag('indented_data_reference', IndentedDataReference)
engine.registerTag('data', Data)
engine.registerTag('octicon', Octicon)
engine.registerTag('ifversion', Ifversion)
for (const tag of toolTags) {
engine.registerTag(tag, Tool)
}
for (const tag in spotlightTags) {
engine.registerTag(tag, Spotlight)
}
engine.registerTag('prompt', Prompt)
/**
* Like the `size` filter, but specifically for
* getting the number of keys in an object
*/
engine.registerFilter('obj_size', (input) => {
if (!input) return 0
return Object.keys(input).length
})
/**
* Returns the version number of a GHES version string
* ex: enterprise-server@2.22 => 2.22
*/
engine.registerFilter('version_num', (input) => {
return input.split('@')[1]
})
/**
* Convert the input to a slug
*/
engine.registerFilter('slugify', (input) => {
const slugger = new GithubSlugger()
return slugger.slug(input)
})