From 4fbaa69a5a888a3e2d554501309e46446d1ca3cd Mon Sep 17 00:00:00 2001 From: Struchkov Mark Date: Thu, 5 Sep 2024 22:18:41 +0300 Subject: [PATCH] added YandexMetrika --- quartz/components/_YandexMetrika.tsx | 29 ++++++++++++++++++++++++++++ quartz/components/index.ts | 4 +++- 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 quartz/components/_YandexMetrika.tsx diff --git a/quartz/components/_YandexMetrika.tsx b/quartz/components/_YandexMetrika.tsx new file mode 100644 index 000000000..53623cdc0 --- /dev/null +++ b/quartz/components/_YandexMetrika.tsx @@ -0,0 +1,29 @@ +import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types" +// @ts-ignore + + +const YandexMetrika: QuartzComponent = ({ displayClass, cfg }: QuartzComponentProps) => { + const embedScript = ` + (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(); + for (var j = 0; j < document.scripts.length; j++) {if (document.scripts[j].src === r) { return; }} + 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(98254050, "init", { + clickmap:true, + trackLinks:true, + accurateTrackBounce:true + }); + ` + + return ( + <> + + + + ) +} +export default (() => YandexMetrika) satisfies QuartzComponentConstructor diff --git a/quartz/components/index.ts b/quartz/components/index.ts index 2f75a6bca..aeade816d 100644 --- a/quartz/components/index.ts +++ b/quartz/components/index.ts @@ -25,6 +25,7 @@ import ScrollToTop from "./_ScrollToTop" import GithubSource from "./_GithubSource" import RandomPageButton from "./_RandomPageButton" import Ads from "./_Ads" +import YandexMetrika from "./_YandexMetrika" export { ArticleTitle, @@ -53,5 +54,6 @@ export { GithubSource, ScrollToTop, RandomPageButton, - Ads + Ads, + YandexMetrika }