From 4a6b8fd3551842e89dd15f8181056fe48a3b04f7 Mon Sep 17 00:00:00 2001
From: Wil Kong <alpha0422@gmail.com>
Date: Mon, 15 May 2023 12:34:57 +0000
Subject: [PATCH] Add Baidu Analytics (#808)
---
exampleSite/config.toml | 4 ++++
layouts/_default/baseof.html | 6 +++++-
layouts/partials/analytics/baidu.html | 11 +++++++++++
CONTRIBUTORS.md | 1 +
4 files changed, 21 insertions(+), 1 deletions(-)
diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md
index 89eb5d1..053e72a 100644
--- a/CONTRIBUTORS.md
+++ b/CONTRIBUTORS.md
@@ -129,3 +129,4 @@
- [Jaroslaw Rozanski](https://jarekrozanski.eu)
- [Easton Man](https://github.com/eastonman)
- [Yiğit Altınay](https://altinay.xyz)
+- [Fei Kong](https://github.com/alpha0422)
diff --git a/exampleSite/config.toml b/exampleSite/config.toml
index ff03254..4a0dc6f 100644
--- a/exampleSite/config.toml
+++ b/exampleSite/config.toml
@@ -66,6 +66,10 @@
# [params.cloudflare]
# token = "token"
+# If you want to use Baidu Analytics(https://tongji.baidu.com) for analytics, add this section
+# [params.baidu]
+# token = "token"
+
# If you want to use Matomo(https://matomo.org) for analytics, add this section
# [params.matomo]
# siteID = "ABCDE" # Default value is "1", overwrite this if you are cloud-hosting
diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html
index 834809e..c62b30f 100644
--- a/layouts/_default/baseof.html
+++ b/layouts/_default/baseof.html
@@ -80,6 +80,10 @@
{{- partial "analytics/cloudflare" . -}}
{{ end }}
+ {{ if and .Site.Params.baidu .Site.Params.baidu.token }}
+ {{- partial "analytics/baidu" . -}}
+ {{ end }}
+
{{ if and .Site.Params.wideAngleAnalytics .Site.Params.wideAngleAnalytics.siteID }}
{{- partial "analytics/wideangle" . -}}
{{ end }}
@@ -115,4 +119,4 @@
{{- partial "body/extensions" . -}}
</body>
-</html>
\ No newline at end of file
+</html>
diff --git a/layouts/partials/analytics/baidu.html b/layouts/partials/analytics/baidu.html
new file mode 100644
index 0000000..e2fcbe9
--- /dev/null
+++ b/layouts/partials/analytics/baidu.html
@@ -0,0 +1,11 @@
+<!-- Baidu Analytics -->
+<script>
+var _hmt = _hmt || [];
+(function() {
+ var hm = document.createElement("script");
+ hm.src = "https://hm.baidu.com/hm.js?{{ $.Site.Params.baidu.token }}";
+ var s = document.getElementsByTagName("script")[0];
+ s.parentNode.insertBefore(hm, s);
+})();
+</script>
+<!-- End Baidu Web Analytics -->
--
Gitblit v1.10.0