Browse Source

Add fathom tracker when building for production.

Syfaro 2 months ago
parent
commit
e15ff10c18
3 changed files with 19 additions and 0 deletions
  1. 2
    0
      .drone.yml
  2. 1
    0
      config.toml
  3. 16
    0
      themes/fox/layouts/_default/baseof.html

+ 2
- 0
.drone.yml View File

@@ -1,6 +1,8 @@
1 1
 pipeline:
2 2
   build:
3 3
     image: cibuilds/hugo:0.49
4
+    environment:
5
+      - HUGO_ENV=production
4 6
     commands:
5 7
       - hugo --minify
6 8
 

+ 1
- 0
config.toml View File

@@ -9,6 +9,7 @@ relativeURLs = true
9 9
 [params]
10 10
   description = "Hi. I'm a purple fox."
11 11
   peppershrike = "https://peppershrike.huefox.com"
12
+  fathom = "//fathom.syfaro.net/tracker.js"
12 13
 
13 14
 [imaging]
14 15
   resampleFilter = "Lanczos"

+ 16
- 0
themes/fox/layouts/_default/baseof.html View File

@@ -44,6 +44,22 @@
44 44
             🦊🐾
45 45
         {{ end }}
46 46
     </footer>
47
+
48
+    {{ if and (eq "production" (getenv "HUGO_ENV")) .Site.Params.fathom }}
49
+        <script>
50
+            (function(f, a, t, h, o, m){
51
+                a[h]=a[h]||function(){
52
+                    (a[h].q=a[h].q||[]).push(arguments)
53
+                };
54
+                o=f.createElement('script'),
55
+                m=f.getElementsByTagName('script')[0];
56
+                o.async=1; o.src=t; o.id='fathom-script';
57
+                m.parentNode.insertBefore(o,m)
58
+            })(document, window, '{{ .Site.Params.fathom }}', 'fathom');
59
+
60
+            fathom('trackPageview');
61
+        </script>
62
+    {{ end }}
47 63
 </body>
48 64
 
49 65
 </html>

Loading…
Cancel
Save