-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy pathindex.js
52 lines (39 loc) · 1.26 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
'use strict';
module.exports = {
name: require('./package').name,
contentFor(type, config) {
let content = '';
if (type === 'head') {
let src = '//maps.googleapis.com/maps/api/js';
let gMapConfig = config['g-map'] || {};
let params = [];
if (gMapConfig.key) {
params.push(`key=${encodeURIComponent(gMapConfig.key)}`);
}
if (gMapConfig.version) {
params.push(`v=${encodeURIComponent(gMapConfig.version)}`);
}
if (gMapConfig.client) {
params.push(`client=${encodeURIComponent(gMapConfig.client)}`);
}
if (gMapConfig.channel) {
params.push(`channel=${encodeURIComponent(gMapConfig.channel)}`);
}
if (gMapConfig.libraries && gMapConfig.libraries.length) {
params.push(`libraries=${encodeURIComponent(gMapConfig.libraries.join(','))}`);
}
if (gMapConfig.language) {
params.push(`language=${encodeURIComponent(gMapConfig.language)}`);
}
if (gMapConfig.protocol) {
src = `${gMapConfig.protocol}:${src}`;
}
src = `${src}?${params.join('&')}`;
content = `<script type="text/javascript" src="${src}"></script>`;
if (gMapConfig.exclude) {
content = '';
}
}
return content;
}
};