forked from probot/attachments
-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.js
52 lines (32 loc) · 1.25 KB
/
template.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
module.exports = function (attachment) {
let str = ''
if (attachment.pretext) str += `${attachment.pretext}\n`
str += '<blockquote>'
// "thumb_url": "http://example.com/path/to/thumb.png",
if (attachment.thumb_url) { str += `<img src="${attachment.thumb_url}" width="48" align="right">` }
if (attachment.author_name) {
str += '<div>'
if (attachment.author_icon) { str += `<img src="${attachment.author_icon}" height="14"> ` }
if (attachment.author_link) { str += `<a href="${attachment.author_link}">${attachment.author_name}</a>` } else { str += attachment.author_name }
str += '</div>'
}
if (attachment.title) {
str += `<div><strong>`
if (attachment.title_link) { str += `<a href="${attachment.title_link}">${attachment.title}</a>` } else { str += attachment.title }
str += `</strong></div>`
}
if (attachment.text) str += `<div>${attachment.text}</div>`
// TODO: fields
if (attachment.image_url) str += `<br><img src="${attachment.image_url}">`
if (attachment.footer) {
str += '<h6>'
if (attachment.footer_icon) {
str += `<img src="${attachment.footer_icon}" height="14"> `
}
str += attachment.footer
str += '</h6>'
// TODO: ts?
}
str += '</blockquote>'
return str
}