-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbannerbear.js
65 lines (52 loc) · 1.3 KB
/
bannerbear.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
62
63
64
const { Bannerbear } = require('bannerbear');
const bb = new Bannerbear(process.env.BB_API_KEY);
const TEMPLATE_ID = 'k4qoBVDy1g7rDzN0gj'; //replace this with your own template ID
exports.generateWallpaper = async function(todoTasks, calendarObj) {
var modifications = [
{
"name": "todo_title_work",
"text": "Work",
},
{
"name": "todo_title_personal",
"text": "Personal",
},
{
"name": "todo_title_others",
"text": "Others",
},
{
"name": "month_title",
"text": calendarObj.month,
},
{
"name": "month_dates_text",
"text": calendarObj.dates,
}
];
for (category in todoTasks) {
var bb_object = {
"name": "",
"text": "",
};
const todo = todoTasks[category];
var todoText = '';
for(i in todo) {
todoText += `- ${todo[i]}\n`
}
switch(category){
case 'Personal':
bb_object.name = 'todo_item_personal';
break;
case 'Work':
bb_object.name = 'todo_item_work';
break;
default:
bb_object.name = 'todo_item_others'
}
bb_object.text = todoText;
modifications.push(bb_object);
}
const images = await bb.create_image(TEMPLATE_ID, {"modifications": modifications}, true);
return images.image_url_png;
}