Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/reuixiy/hugo-theme-meme.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorgiy Mogelashvili <gmogelashvili@gmail.com>2021-04-14 04:56:37 +0300
committerGitHub <noreply@github.com>2021-04-14 04:56:37 +0300
commitabd67d8e27d9cf253b08dcd49d0af4f6de9dab07 (patch)
tree2844e6fc4364d6599a9b292cf4e801533eac35dd
parenteb0aecd3a6e694491e7c98ab499427c7958ffa82 (diff)
feat: Add support for Yandex.Metrika (#323)
To configure the Yandex.Metrika counter, please specify `yandexMetrikaId` parameter with you y.metrika Id in your config.toml.
-rw-r--r--config-examples/en/config.toml10
-rw-r--r--config-examples/zh-cn/config.toml9
-rw-r--r--config-examples/zh-tw/config.toml9
-rw-r--r--layouts/partials/head.html5
-rw-r--r--layouts/partials/third-party/yandex-metrika.html16
5 files changed, 49 insertions, 0 deletions
diff --git a/config-examples/en/config.toml b/config-examples/en/config.toml
index e0fe926..920a199 100644
--- a/config-examples/en/config.toml
+++ b/config-examples/en/config.toml
@@ -712,6 +712,16 @@ uglyURLs = false
######################################
+ # Yandex.Metrika
+ # https://metrika.yandex.ru/
+
+ # Note: render only in production
+ # environment
+
+ yandexMetrikaId = ""
+
+
+ ######################################
# Post Settings
# The color change duration of the
diff --git a/config-examples/zh-cn/config.toml b/config-examples/zh-cn/config.toml
index 2aa3cac..4fa864b 100644
--- a/config-examples/zh-cn/config.toml
+++ b/config-examples/zh-cn/config.toml
@@ -659,6 +659,15 @@ uglyURLs = false
######################################
+ # Yandex.Metrika
+ # https://metrika.yandex.ru/
+
+ # 说明:仅在生产环境(production)下渲染
+
+ yandexMetrikaId = ""
+
+
+ ######################################
# 文章设置
# 超链接的颜色变化持续时间(单位:秒)
diff --git a/config-examples/zh-tw/config.toml b/config-examples/zh-tw/config.toml
index b48a1f5..cb5405b 100644
--- a/config-examples/zh-tw/config.toml
+++ b/config-examples/zh-tw/config.toml
@@ -659,6 +659,15 @@ uglyURLs = false
######################################
+ # Yandex.Metrika
+ # https://metrika.yandex.ru/
+
+ # 說明:僅在生產環境(production)下渲染
+
+ yandexMetrikaId = ""
+
+
+ ######################################
# 文章設定
# 超連結的顏色變化持續時間(單位:秒)
diff --git a/layouts/partials/head.html b/layouts/partials/head.html
index 693792d..2c84fc1 100644
--- a/layouts/partials/head.html
+++ b/layouts/partials/head.html
@@ -108,5 +108,10 @@
{{ partial "third-party/google-adsense-auto.html" . }}
{{- end }}
+ <!-- Yandex.Metrika -->
+ {{ if and .Site.Params.yandexMetrikaId (eq hugo.Environment "production") }}
+ {{ partial "third-party/yandex-metrika.html" . }}
+ {{- end }}
+
{{ partial "custom/head.html" . }}
</head>
diff --git a/layouts/partials/third-party/yandex-metrika.html b/layouts/partials/third-party/yandex-metrika.html
new file mode 100644
index 0000000..7177b0e
--- /dev/null
+++ b/layouts/partials/third-party/yandex-metrika.html
@@ -0,0 +1,16 @@
+{{ with .Site.Params.yandexMetrikaId }}
+ <!-- Yandex.Metrika counter -->
+ <script type="text/javascript" >
+ (function(m,e,t,r,i,k,a){m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)};
+ m[i].l=1*new Date();k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a)})
+ (window, document, "script", "https://mc.yandex.ru/metrika/tag.js", "ym");
+
+ ym({{ . }}, "init", {
+ clickmap:true,
+ trackLinks:true,
+ accurateTrackBounce:true
+ });
+ </script>
+ <noscript><div><img src="https://mc.yandex.ru/watch/{{ . }}" style="position:absolute; left:-9999px;" alt="" /></div></noscript>
+ <!-- /Yandex.Metrika counter -->
+{{ end }} \ No newline at end of file