-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelpers.js
61 lines (51 loc) · 1.1 KB
/
helpers.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
const tag = require('./index.js').tag
module.exports.link = function(url='#', text='', title='', rhs=[]) {
text = text || url
title = title || text
return [
tag('a', {href: url, title: title}, [text]),
rhs
]
}
module.exports.embed = function(url='#', width='560', height='315', rhs=[]) {
return [
tag(
'div',
{
style: `
position: relative;
width: 100%;
padding-bottom: calc(100% / (${width} / ${height}));
`
},
tag(
'iframe',
{
src: url,
width: width,
height: height,
frameborder: 0,
style: `
position: absolute;
width: 100%;
height: 100%;
top: 50%;
left: 50%;
transform: translateX(-50%) translateY(-50%);
`
}
)
),
rhs
]
}
module.exports.siblings = function(name='p', content=[], rhs=[]) {
return [
content.map(sibling =>
Array.isArray(sibling)
? tag(name, sibling[0], sibling[1])
: tag(name, [], sibling)
),
rhs
]
}