forked from github/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
46 lines (39 loc) · 1.42 KB
/
index.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
40
41
42
43
44
45
46
import GithubSlugger from 'github-slugger'
import renderContent from './renderContent.js'
import { ExtendedMarkdown, tags } from '../liquid-tags/extended-markdown.js'
import IndentedDataReference from '../liquid-tags/indented-data-reference.js'
import Data from '../liquid-tags/data.js'
import Octicon from '../liquid-tags/octicon.js'
import Ifversion from '../liquid-tags/ifversion.js'
renderContent.liquid.registerTag('indented_data_reference', IndentedDataReference)
renderContent.liquid.registerTag('data', Data)
renderContent.liquid.registerTag('octicon', Octicon)
renderContent.liquid.registerTag('ifversion', Ifversion)
for (const tag in tags) {
// Register all the extended markdown tags, like {% note %} and {% warning %}
renderContent.liquid.registerTag(tag, ExtendedMarkdown)
}
/**
* Like the `size` filter, but specifically for
* getting the number of keys in an object
*/
renderContent.liquid.registerFilter('obj_size', (input) => {
if (!input) return 0
return Object.keys(input).length
})
/**
* Returns the version number of a GHES version string
* ex: [email protected] => 2.22
*/
renderContent.liquid.registerFilter('version_num', (input) => {
return input.split('@')[1]
})
/**
* Convert the input to a slug
*/
renderContent.liquid.registerFilter('slugify', (input) => {
const slugger = new GithubSlugger()
return slugger.slug(input)
})
export default renderContent
export const liquid = renderContent.liquid