forked from Spiderpig86/Spiderpig86
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
247 lines (228 loc) · 8.21 KB
/
index.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
/**
* README Generator
*/
const md = require('markdown-it')({
html: true,
linkify: true,
breaks: true
});
const mdEmoji = require('markdown-it-emoji');
const fs = require('fs');
const axios = require('axios').default;
md.use(mdEmoji);
const BLOG_HOST = `https://blog.stanleylim.me`;
/* README Sections */
const introTitle = generateTitle(2, `Hey :wave:, I'm ${generateLink('Stanley', 'https://stanleylim.me/')}`);
const introDescription = `I'm currently a software engineer **${generateLink(
'@aws',
'https://aws.amazon.com/'
)}** based in 🌁 Seattle. I am working on some side projects, learning a couple new dishes, and trying to conquer the world as Tannu Tuva in HOI4.`;
const badgeConfigs = [
{
name: 'Website',
badgeText: 'stanleylim.me',
labelBgColor: '4E69C8',
logoBgColor: '4E69C8',
logo: 'Firefox',
link: 'https://stanleylim.me',
},
{
name: 'Medium',
badgeText: '@serbis',
labelBgColor: '14c767',
logoBgColor: '14c767',
logo: 'Medium',
link: 'https://medium.com/@serbis',
},
{
name: 'LinkedIn',
badgeText: '@serbis',
labelBgColor: '0077B5',
logoBgColor: '0077B5',
logo: 'LinkedIn',
link: 'https://www.linkedin.com/in/serbis/',
},
{
name: 'DevTo',
badgeText: '@spiderpig86',
labelBgColor: '0A0A0A',
logoBgColor: '0A0A0A',
logo: 'dev.to',
link: 'https://dev.to/spiderpig86',
},
{
name: 'Spotify',
badgeText: '@Stanley%20Lim',
labelBgColor: '1ED760',
logoBgColor: 'fff',
logo: 'Spotify',
link: 'https://open.spotify.com/user/1235099575',
},
];
const badges = badgeConfigs.reduce((result, config) => result + ' ' + generateBadge(config), '');
const gif = `<img align="right" src="https://media1.giphy.com/media/13HgwGsXF0aiGY/giphy.gif" />`;
const factsTitle = generateTitle(2, `:zap: A Few Quick Facts`);
const factsConfigs = [
`🔭 I’m currently working on [Cirrus](https://github.com/Spiderpig86/Cirrus).`,
`🧐 Learning about **serverless architectures**, **distributed systems**, and a bit of **ML**.`,
`👨💻 Most of my projects are available on [Github](https://github.com/Spiderpig86).`,
`📝 I regulary write articles on [my blog](${BLOG_HOST}).`,
`💬 Ping me about **react, koa, security, and cloud stuff**.`,
`📙 Check out my [resume](https://www.stanleylim.me/resume/resume.pdf).`,
`🎉 Fun Fact: 我也会讲中文。`,
];
const facts = factsConfigs.reduce((result, fact) => result + `\n - ${fact}`, '');
const postsTitle = generateTitle(2, `:black_nib: Recent Posts`)
const toolsTitle = generateTitle(2, `:rocket: Some Tools I Use`)
const toolsIconSize = 25;
const toolsConfig = [
{
src: 'https://raw.githubusercontent.com/devicons/devicon/master/icons/react/react-original-wordmark.svg',
alt: 'react',
},
{
src: 'https://raw.githubusercontent.com/devicons/devicon/master/icons/angularjs/angularjs-original.svg',
alt: 'angular-js',
},
{
src: 'https://raw.githubusercontent.com/devicons/devicon/master/icons/vuejs/vuejs-original.svg',
alt: 'vue',
},
{
src: 'https://raw.githubusercontent.com/devicons/devicon/master/icons/bootstrap/bootstrap-plain.svg',
alt: 'bootstrap',
},
{
src: 'https://raw.githubusercontent.com/devicons/devicon/master/icons/css3/css3-original-wordmark.svg',
alt: 'css3',
},
{
src: 'https://raw.githubusercontent.com/devicons/devicon/master/icons/gulp/gulp-plain.svg',
alt: 'gulp',
},
{
src: 'https://raw.githubusercontent.com/devicons/devicon/master/icons/java/java-original-wordmark.svg',
alt: 'java',
},
{
src: 'https://raw.githubusercontent.com/devicons/devicon/master/icons/javascript/javascript-original.svg',
alt: 'javascript',
},
{
src: 'https://raw.githubusercontent.com/devicons/devicon/master/icons/typescript/typescript-original.svg',
alt: 'typescript',
},
{
src: 'https://raw.githubusercontent.com/devicons/devicon/master/icons/dot-net/dot-net-original.svg',
alt: '.NET',
},
{
src: 'https://raw.githubusercontent.com/devicons/devicon/master/icons/mongodb/mongodb-original.svg',
alt: 'mongodb',
},
{
src: 'https://raw.githubusercontent.com/devicons/devicon/master/icons/mysql/mysql-original-wordmark.svg',
alt: 'mysql',
},
{
src: 'https://raw.githubusercontent.com/devicons/devicon/master/icons/redis/redis-original-wordmark.svg',
alt: 'redis',
},
{
src: 'https://raw.githubusercontent.com/devicons/devicon/master/icons/nodejs/nodejs-original-wordmark.svg',
alt: 'nodejs',
},
{
src: 'https://www.vectorlogo.zone/logos/springio/springio-icon.svg',
alt: 'spring',
},
{
src: 'https://raw.githubusercontent.com/devicons/devicon/master/icons/python/python-original-wordmark.svg',
alt: 'python',
},
{
src: 'https://raw.githubusercontent.com/devicons/devicon/master/icons/nginx/nginx-original.svg',
alt: 'nginx',
},
{
src: 'https://raw.githubusercontent.com/devicons/devicon/master/icons/cucumber/cucumber-plain.svg',
alt: 'cucumber',
},
{
src: 'https://raw.githubusercontent.com/devicons/devicon/master/icons/heroku/heroku-plain.svg',
alt: 'heroku',
},
{
src: 'https://raw.githubusercontent.com/devicons/devicon/master/icons/travis/travis-plain.svg',
alt: 'travis',
},
{
src: 'https://raw.githubusercontent.com/github/explore/80688e429a7d4ef2fca1e82350fe8e3517d3494d/topics/aws/aws.png',
alt: 'aws',
},
{
src: 'https://www.vectorlogo.zone/logos/google_cloud/google_cloud-icon.svg',
alt: 'gcp',
},
{
src: 'https://raw.githubusercontent.com/devicons/devicon/master/icons/docker/docker-original.svg',
alt: 'Docker',
},
{
src: 'https://www.vectorlogo.zone/logos/kubernetes/kubernetes-icon.svg',
alt: 'Kubernetes',
},
];
const tools = toolsConfig.reduce((result, toolConfig) => result + '\n' + generateIcon(toolConfig, toolsIconSize), '');
const stats = `<img src="https://github-readme-stats.vercel.app/api?username=spiderpig86&show_icons=true&count_private=true" alt="spiderpig86" />`;
const visitors = `![visitors](https://visitor-badge.glitch.me/badge?page_id=Spiderpig86.Spiderpig86)`;
(async () => {
// Get blog entries
const response = await axios.get(`${BLOG_HOST}/page-data/index/page-data.json`);
const postData = response.data.result.data.allMarkdownRemark.edges;
let posts = ``;
postData.slice(0, Math.min(postData.length, 5)).map(post => {
const title = post.node.frontmatter.title;
const date = post.node.frontmatter.date;
const path = post.node.frontmatter.path;
posts += `<li><a target="_blank" href="${BLOG_HOST}${path}">${title} — ${date}</a></li>`;
});
const content = `${introTitle}\n
${introDescription}\n
${badges}\n
${gif}\n
${factsTitle}\n
${facts}\n
${postsTitle}\n
<details>
<summary>Explore</summary>
${posts}\n
</details>\n
<a target="_blank" href="${BLOG_HOST}">Read More</a>\n
${toolsTitle}\n
<p align="left">\n
${tools}\n
</p>\n
${stats}\n
${visitors}
`;
const markdownContent = md.render(content);
fs.writeFile('README.md', markdownContent, (err) => {
if (err) {
return console.error(err);
}
console.info(`Writing to README.md`);
});
})();
function generateBadge(badgeConfig) {
return `[![${badgeConfig.name} Badge](https://img.shields.io/badge/-${badgeConfig.badgeText}-${badgeConfig.labelBgColor}?style=flat-square&labelColor=${badgeConfig.logoBgColor}&logo=${badgeConfig.logo}&link=${badgeConfig.link})](${badgeConfig.link})`;
}
function generateIcon(iconConfig, toolsIconSize) {
return `<img src="${iconConfig.src}" alt="${iconConfig.alt}" width="${toolsIconSize}" height="${toolsIconSize}" />`;
}
function generateTitle(size, title) {
return `${'#'.repeat(size)} ${title}`;
}
function generateLink(label, link) {
return `[${label}](${link})`;
}