-
-
Notifications
You must be signed in to change notification settings - Fork 140
Expand file tree
/
Copy pathsimple-analytics-plugin.ts
More file actions
35 lines (33 loc) 路 1.22 KB
/
Copy pathsimple-analytics-plugin.ts
File metadata and controls
35 lines (33 loc) 路 1.22 KB
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
import type {PluginModule} from '@docusaurus/types';
// Simple Analytics: privacy-friendly, cookieless analytics. The script is only
// injected in production builds; Simple Analytics additionally ignores localhost
// on its own. SPA navigation is tracked automatically.
const simpleAnalyticsPlugin: PluginModule<void> = () => {
return {
name: 'simple-analytics-plugin',
injectHtmlTags() {
if (process.env.NODE_ENV !== 'production') {
return {};
}
return {
headTags: [
{
tagName: 'script',
attributes: {
async: true,
src: 'https://scripts.simpleanalyticscdn.com/latest.js',
},
},
],
postBodyTags: [
{
tagName: 'noscript',
innerHTML:
'<img src="https://queue.simpleanalyticscdn.com/noscript.gif" alt="" referrerpolicy="no-referrer-when-downgrade" />',
},
],
};
},
};
};
export default simpleAnalyticsPlugin;