-
Notifications
You must be signed in to change notification settings - Fork 13
/
build-config.js
66 lines (63 loc) · 2.05 KB
/
build-config.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
const lookup = require('country-code-lookup');
const formatDate = require('date-fns/format');
// Files and directories used in the build process
module.exports = {
VIEWS_DIR: __dirname + '/views',
PARTIALS_DIR: __dirname + '/views/partials',
STYLES_DIR: __dirname + '/styles',
OUTPUT_DIR: __dirname + '/public',
TEMPLATE_FILENAME: 'resume.hbs',
HTML_FILENAME: 'index.html',
CSS_FILENAME: 'resume.css',
RESUME_PATH: __dirname + '/resume.json',
FALLBACK_RESUME_PATH: __dirname + '/resume-sample.json',
helpers: {
uppercase: function (str) {
return str.toUpperCase();
},
lowercase: function (str) {
return str.toLowerCase();
},
removeProtocol: function (url) {
const regex = /^.+:\/\/(.*)/i; // ignore case
const match = url.match(regex);
if (match && match[1]) {
return match[1].replace(/^[\/]+|[\/]+$/g, '');
} else {
return url;
}
},
concat: function (...args) {
// Last element seems to be some handlebars internal object, so just remove it
const items = args.slice(0, -1);
return items.join('');
},
array: function (...args) {
// Last element seems to be some handlebars internal object, so just remove it
return args.slice(0, -1);
},
formatAddress: function (location) {
const { address, city, region, countryCode, postalCode } = location;
let text = '';
/**
* I prefer to only list the city, region and country, but if you want to
* show the whole address just uncomment the lines for each address part.
*/
//if (address) text += `${address}, `;
if (city) text += city;
if (region) text += `, ${region}`;
if (countryCode) {
const found = lookup.byIso(countryCode);
if (found) {
text += `, ${found.country}`;
}
}
// if (postalCode) text += `, ${postalCode}`;
return text;
},
formatDate: function (string) {
const date = new Date(`${string} 00:00:01`);
return formatDate(date, 'MMM yyyy');
}
}
};