forked from lorenzodalaqua/jsonresume-theme-autumn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-config.js
101 lines (88 loc) · 2.86 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
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
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;//
// console.debug('location', location);
var 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}, `;
// with(location) {
// if (city) text.push(city);
// if (region) text.push(region);
// if (countryCode) {
// const found = lookup.byIso(countryCode);
// if (found) {
// text.push(found.country);
// }
// }
// // if (postalCode) text.push(postalCode);
// }
// text.push(location.city);
text.push(location.region);
text.push(lookup.byIso(location.countryCode).country);
/*
Buffer to String
- fastest way of concating strings
- no dealing with trailing commas
- or missing/blank values
*/
text = text.join(', ');
// console.debug('formatAddress', 'text', text)
return text;
},
formatDate: function (string) {
const date = new Date(`${string} 00:00:01`);
return formatDate(date, 'MMM yyyy');
},
/**
* Support optional `profiles.
* @param {any} icon
* @param {any} fallback
* @returns {any}
*/
iconOrValue: function(icon, fallback) {
// console.debug('iconOrValue', icon, fallback);
return typeof icon === 'string' && icon.length > 0 ? icon : fallback.toLowerCase();
}
}
};