-
Notifications
You must be signed in to change notification settings - Fork 1
/
template.ts
83 lines (75 loc) · 1.87 KB
/
template.ts
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import { Liquid } from 'liquidjs'
import { split } from './shlex'
export const liquid = new Liquid()
liquid.registerTag('youtube', {
parse (token) {
this.href = split(token.args)[0]
},
render () {
return this.href ? `
<iframe
width="560" height="315"
style="height: 315px;"
src="https://www.youtube.com/embed/${encodeURIComponent(this.href)}"
frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen
></iframe>` : ''
}
})
liquid.registerTag('speak', {
parse (token) {
const [href, str] = split(token.args)
this.word = href
this.lang = str || 'zh'
},
render () {
const href = `https://speak-btn.now.sh/btn?q=${encodeURIComponent(this.word)}&lang=${encodeURIComponent(this.lang)}`
return this.word ? `
<iframe
src="${href}"
style="width: 20px; height: 20px; display: inline-block;"
frameborder="0" allowtransparency="true"
></iframe>` : ''
}
})
liquid.registerTag('reveal', {
parse (token) {
this.href = split(token.args)[0]
},
render () {
return this.href ? `
<iframe
class="a-reveal"
src="${`${process.env.BASE_URL || ''}reveal.html?slug=${encodeURIComponent(this.href)}`}"
sandbox frameborder="0"
>
</iframe>` : ''
}
})
liquid.registerTag('pdf', {
parse (token) {
this.href = split(token.args)[0]
},
render () {
return this.href ? `
<iframe
class="a-pdf"
src="${encodeURI(this.href)}"
sandbox frameborder="0"
>
</iframe>` : ''
}
})
liquid.registerTag('gpdf', {
parse (token) {
this.href = split(token.args)[0]
},
render () {
return this.href ? `
<iframe
class="a-pdf a-gpdf"
src="https://drive.google.com/file/d/${encodeURIComponent(this.href)}/preview"
sandbox frameborder="0"
>
</iframe>` : ''
}
})