Quellcode durchsuchen

Add support for microanalytics.io (#765)

### Prerequisites

Put an `x` into the box(es) that apply:

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

### Description

This PR introduces support for another analytics provider:
https://microanalytics.io/
This change provides new file in `layouts/partials/analytics` for the
introduced provider. Documentation has been respectively updated.


### Issues Resolved

None

### Checklist

Put an `x` into the box(es) that apply:

#### General

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

#### Resources

- [ ] 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

Co-authored-by: Luiz F. A. de Prá <luizdepra@users.noreply.github.com>
Michał Pawlik vor 2 Jahren
Ursprung
Commit
5cd634aa14

+ 1 - 0
CONTRIBUTORS.md

@@ -124,3 +124,4 @@
 - [ShortArrow](https://github.com/ShortArrow)
 - [Martin Hellspong](https://github.com/marhel)
 - [Robert Tucker](https://github.com/robertwtucker)
+- [Michał Pawlik](https://michalp.net)

+ 8 - 0
docs/configurations.md

@@ -100,6 +100,14 @@ Follow [these steps](https://gohugo.io/templates/internal/#configure-google-anal
     connectionString = "connectionstring" # https://docs.microsoft.com/en-us/azure/azure-monitor/app/sdk-connection-string
 ```
 
+#### microanalytics.io
+
+```toml
+[params.microAnalytics]
+    id = "ABCDE"
+    dnt = "false" # respect DNT tracker, "true" by default
+```
+
 ### Commenting Systems
 
 Comments are displayed within post pages, but can be disabled with `disableComments` front-matter.

+ 5 - 0
exampleSite/config.toml

@@ -77,6 +77,11 @@ customRemoteJS = []
 # [params.applicationInsights]
 # connectionString = "connectionString"
 
+# If you want to use microanalytics.io for analytics, add this section
+# [params.microAnalytics]
+# id = "ABCDE"
+# dnt = "false" # respect DNT tracker, "true" by default
+
 # If you want to implement a Content-Security-Policy, add this section
 # [params.csp]
 # childsrc = ["'self'"]

+ 5 - 1
layouts/_default/baseof.html

@@ -87,7 +87,11 @@
   {{ end }}
 
   {{ if and .Site.Params.applicationInsights .Site.Params.applicationInsights.connectionString }}
-    {{- partial "analytics/applicationinsights" . -}}
+  {{- partial "analytics/applicationinsights" . -}}
+  {{ end }}
+
+  {{ if and .Site.Params.microAnalytics .Site.Params.microAnalytics.id }}
+  {{- partial "analytics/microanalyticsio" . -}}
   {{ end }}
 
   {{- partial "body/extensions" . -}}

+ 8 - 0
layouts/partials/analytics/microanalyticsio.html

@@ -0,0 +1,8 @@
+<script 
+    async
+    defer
+    data-host="https://microanalytics.io"
+    data-dnt="{{ .Site.Params.microAnalytics.dnt | default "true" }}"
+    src="https://microanalytics.io/js/script.js"
+    id="{{ .Site.Params.microAnalytics.id }}">
+</script>