فهرست منبع

feat(analytics): Add umami analytics (#787)

### Prerequisites

- [ ] This pull request fixes a bug.
- [x] This pull request adds a feature.
- [ ] This pull request introduces breaking change.

### Description

Add [Umami](https://umami.is) analytic.

I use umami myself, and I added umami if anyone would like an easy way
to integrate with umami.

### Issues Resolved

N/A

### Checklist

#### General

- [x] Describe what changes are being made
- [x] Explain why and how the changes were necessary and implemented
respectively
- [x] Reference issue with `#<ISSUE_NO>` if applicable

#### Resources

- [x] If you have changed any SCSS code, run `make release` to
regenerate all CSS files

#### Contributors

- [x] Add yourself to `CONTRIBUTORS.md` if you aren't on it already
Easton Man 2 سال پیش
والد
کامیت
c8e6aa6d91
5فایلهای تغییر یافته به همراه25 افزوده شده و 6 حذف شده
  1. 1 0
      CONTRIBUTORS.md
  2. 1 0
      docs/analytics.md
  3. 7 0
      docs/analytics/umami.md
  4. 12 6
      layouts/_default/baseof.html
  5. 4 0
      layouts/partials/analytics/umami.html

+ 1 - 0
CONTRIBUTORS.md

@@ -127,3 +127,4 @@
 - [Michał Pawlik](https://michalp.net)
 - [Kilian Kluge](https://github.com/ionicsolutions)
 - [Jaroslaw Rozanski](https://jarekrozanski.eu)
+- [Easton Man](https://github.com/eastonman)

+ 1 - 0
docs/analytics.md

@@ -13,4 +13,5 @@
 * [Matomo](https://matomo.org/) - [documentation](/docs/analytics/matomo.md)
 * [Micro Analytics](https://microanalytics.io/) - [documentation](/docs/analytics/microanalytics.md)
 * [Plausible Analytics](https://plausible.io/) - [documentation](/docs/analytics/plausible.md)
+* [Umami](https://umami.is/) - [documentation](/docs/analytics/umami.md)
 * [Wide Angle Analytics](https://wideangle.co/) - [documentation](/docs/analytics/wideangle.md)

+ 7 - 0
docs/analytics/umami.md

@@ -0,0 +1,7 @@
+# Umami
+
+```toml
+[params.umami]
+    siteID = "ABCDE"
+    serverURL = "analytics.example.com"
+```

+ 12 - 6
layouts/_default/baseof.html

@@ -1,9 +1,10 @@
 <!DOCTYPE html>
 <html lang="{{ .Site.Language.Lang }}">
-  <head>
-    <title>{{ block "title" . }}{{ .Site.Title }}{{ end }}</title>
-    {{ partial "head.html" . }}
-  </head>
+
+<head>
+  <title>{{ block "title" . }}{{ .Site.Title }}{{ end }}</title>
+  {{ partial "head.html" . }}
+</head>
 
 {{ $csClass := "colorscheme-light" }}
 {{ if eq .Site.Params.colorScheme "dark" }}
@@ -25,7 +26,8 @@
   </main>
 
   {{ if .HasShortcode "mermaid" }}
-  <script src="https://cdn.jsdelivr.net/npm/mermaid@9.3.0/dist/mermaid.min.js" integrity="sha256-QdTG1YTLLTwD3b95jLqFxpQX9uYuJMNAtVZgwKX4oYU=" crossorigin="anonymous"></script>
+  <script src="https://cdn.jsdelivr.net/npm/mermaid@9.3.0/dist/mermaid.min.js"
+    integrity="sha256-QdTG1YTLLTwD3b95jLqFxpQX9uYuJMNAtVZgwKX4oYU=" crossorigin="anonymous"></script>
   <script>
     mermaid.initialize({ startOnLoad: true });
   </script>
@@ -102,7 +104,11 @@
   {{- partial "analytics/yandex-metrika" . -}}
   {{ end }}
 
+  {{ if and .Site.Params.umami .Site.Params.umami.siteID }}
+  {{- partial "analytics/umami" . -}}
+  {{ end }}
+
   {{- partial "body/extensions" . -}}
 </body>
 
-</html>
+</html>

+ 4 - 0
layouts/partials/analytics/umami.html

@@ -0,0 +1,4 @@
+<!-- Umami Analytics START -->
+<script async defer data-website-id="{{ .Site.Params.umami.websiteId }}"
+    src="{{ .Site.Params.umami.serverURL }}/umami.js"></script>
+<!-- Umami Analytics END -->