-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgridsome.client.js
39 lines (31 loc) · 1.09 KB
/
gridsome.client.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
export default function (Vue, options, context) {
if (!options.dataDomain) {
console.error("Please supply dataDomain in options for gridsome-plugin-plausible-analytics.")
return;
}
if (options.excludePages && !Array.isArray(options.excludePages)) {
console.error("If supplied, excludePages has to be an array of pages to exclude.");
return;
}
var host = options.customDomain ? options.customDomain : "plausible.io";
var postfix = '';
var excludePages;
var filename;
if (options.excludePages && options.excludePages.length > 0) {
excludePages = options.excludePages.join(', ');
}
if (excludePages) postfix += '.exclusions';
if (options.outboundLinkTracking) postfix += '.outbound-links';
postfix += '.js';
filename = 'script' + postfix;
var script = {
"src": "https://" + host + "/js/" + filename,
"async": true,
"defer": true,
"data-domain": options.dataDomain
};
if (excludePages) {
script["data-exclude"] = excludePages;
}
context.head.script.push(script);
}