-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobsidean.js
140 lines (101 loc) · 2.77 KB
/
obsidean.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
const json = require('./techstars.json');
const _ = require('lodash');
const { v4: uuidv4 } = require('uuid');
var async = require('async')
var template = require('lodash.template');
const fs = require('fs');
var session_tpl = _.template(`
### Session
<%=data[0].session%>
### Accel
[[<%=data[0].accelerator%>]]
### Companies:
<%_.forEach(data, function (u,i) {%>- [[<%=u.name%>]]
<%})%>
`)
var acc_tpl = _.template(`
### Accelerator
<%=accelerator%>
### Sessions:
<%_.forEach(sessions, function (u,i) {%>- [[<%=u%>]]
<%})%>
`)
var founder_tpl = _.template(`
### Founder
<%=data[0]%>
### Company:
[[<%=company.name%>]]
`)
var tpl = _.template(`
![<%=item.name%>|50x50](<%=item.logo_url%>)
#### <%=item.name%>
<%=item.description%>
### Stage:
<%=item.stage%> - <%=item.type%>
### Current Status:
<%=item.status%>
### Where:
<%=item.city%>, <%=item.state%>, <%=item.country%>
### Site:
<%=item.website%>
<%=item.demo_day_pitch_video_url%>
<%=item.crunchbase_profile%>
### Current Status:
<%=item.status%>
### Cohort/Sessions:
<%=item.accelerator%>, in <%=item.session%>
### Founders:
<%_.forEach(item.founder_profile_arrays, function (u,i) {%>
![<%=u[0]%>|50x50](<%=u[2]%>) <%=u[0]%> (<%=u[1] || ''%>) [LinkedIn](https://<%=u[3]%>) [[<%=u[0] || ''%>]]
<%})%>
`
);
var jsonData = json;
var q = async.queue(function(task, callback) {
fs.writeFile(task.filename, task.html, (err) => {
if (err) {
console.log('Failed', task.filename, err.message);
}
callback();
});
}, 1);
// assign a callback
q.drain(function() {
console.log('all items have been processed');
});
async function main() {
let totalFounders = 0;
_.forEach(jsonData, async (item, i) => {
const html = tpl({ 'item': item });
const filename = `./Techstars/Companies/${item.name}.md`
q.push({ filename, html });
_.forEach(item.founder_profile_arrays, async (founder, x) => {
try {
const html = founder_tpl({ data: founder, company: item });
const name = founder[0];
if (name) {
totalFounders++;
const filename = `./Techstars/Founders/${founder[0]}.md`;
q.push({ filename, html });
}
} catch(err) {
console.log(item, founder)
}
})
})
console.log('totalFounders', totalFounders);
var sessions = _.chain(jsonData).groupBy('session').value();
_.forEach(sessions, async (data, key) => {
let filename = `./Techstars/Sessions/${key}.md`
let html = session_tpl({ data: data })
q.push({ filename, html });
})
var accelerators = _.chain(jsonData).groupBy('accelerator').value();
_.forEach(accelerators, async (data, key) => {
let filename = `./Techstars/Accelerators/${key}.md`
let sessions = _.chain(data).map('session').uniq().value();
let html = acc_tpl({ sessions: sessions, accelerator: key })
q.push({ filename, html });
})
}
main();