-
Notifications
You must be signed in to change notification settings - Fork 2
/
build-svg.js
92 lines (80 loc) · 1.99 KB
/
build-svg.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// const WEATHER_API_KEY = process.env.WEATHER_API_KEY
let fs = require("fs");
let got = require("got");
let qty = require("js-quantities");
// let formatDistance = require('date-fns/formatDistance')
// let WEATHER_DOMAIN = 'http://dataservice.accuweather.com'
// const emojis = {
// 1: '☀️',
// 2: '☀️',
// 3: '🌤',
// 4: '🌤',
// 5: '🌤',
// 6: '🌥',
// 7: '☁️',
// 8: '☁️',
// 11: '🌫',
// 12: '🌧',
// 13: '🌦',
// 14: '🌦',
// 15: '⛈',
// 16: '⛈',
// 17: '🌦',
// 18: '🌧',
// 19: '🌨',
// 20: '🌨',
// 21: '🌨',
// 22: '❄️',
// 23: '❄️',
// 24: '🌧',
// 25: '🌧',
// 26: '🌧',
// 29: '🌧',
// 30: '🥵',
// 31: '🥶',
// 32: '💨',
// }
// // Cheap, janky way to have variable bubble width
// dayBubbleWidths = {
// Monday: 235,
// Tuesday: 235,
// Wednesday: 260,
// Thursday: 245,
// Friday: 220,
// Saturday: 245,
// Sunday: 230,
// }
// // Time working at PlanetScale
// const today = new Date()
// const todayDay = new Intl.DateTimeFormat('en-US', { weekday: 'long' }).format(
// today
// )
// const psTime = formatDistance(new Date(2020, 12, 14), today, {
// addSuffix: false,
// })
// // Today's weather
// const locationKey = '18363_PC'
// let url = `forecasts/v1/daily/1day/${locationKey}?apikey=${WEATHER_API_KEY}`
// got(url, { prefixUrl: WEATHER_DOMAIN })
// .then((response) => {
// console.log(response.body)
// let json = JSON.parse(response.body)
// const degF = Math.round(json.DailyForecasts[0].Temperature.Maximum.Value)
// const degC = Math.round(qty(`${degF} tempF`).to('tempC').scalar)
// const icon = json.DailyForecasts[0].Day.Icon
// })
// .catch((err) => {
// // TODO: something better
// console.log(err)
// })
fs.readFile("template.svg", "utf-8", (error, data) => {
if (error) {
return;
}
data = fs.writeFile("chat.svg", data, (err) => {
if (err) {
console.error(err);
return;
}
});
});