nuxt-yandex-metrika 1.0.4 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -3
- package/dist/module.d.ts +1 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +5 -5
- package/dist/runtime/components/yandex-metrika-informer.vue +22 -0
- package/dist/runtime/components/yandex-verification.vue +24 -0
- package/dist/runtime/plugin.mjs +9 -3
- package/dist/runtime/yandex-metrika/YandexMetrika.d.ts +2 -0
- package/dist/runtime/yandex-metrika/YandexMetrika.mjs +8 -3
- package/package.json +1 -1
- package/dist/runtime/yandex-metrika-informer.vue +0 -22
package/README.md
CHANGED
|
@@ -45,6 +45,7 @@ export default defineNuxtConfig({
|
|
|
45
45
|
// debug: process.env.NODE_ENV !== "production",
|
|
46
46
|
// delay: 0,
|
|
47
47
|
// cdn: false,
|
|
48
|
+
// verification: null, // Verification in Yandex Webmaster
|
|
48
49
|
// options: {
|
|
49
50
|
// webvisor: true
|
|
50
51
|
// },
|
|
@@ -76,9 +77,10 @@ For more information:
|
|
|
76
77
|
|
|
77
78
|
## Usage
|
|
78
79
|
|
|
79
|
-
| Component Name | Auto Imported | Description
|
|
80
|
-
|
|
81
|
-
| `<YandexMetrikaInformer />` | ✅ | Shows informer
|
|
80
|
+
| Component Name | Auto Imported | Description |
|
|
81
|
+
|-----------------------------|---------------|----------------------------------|
|
|
82
|
+
| `<YandexMetrikaInformer />` | ✅ | Shows informer |
|
|
83
|
+
| `<YandexVerification />` | ✅ | Verification in Yandex Webmaster |
|
|
82
84
|
|
|
83
85
|
### Methods
|
|
84
86
|
|
package/dist/module.d.ts
CHANGED
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { defineNuxtModule, createResolver, addPlugin,
|
|
1
|
+
import { defineNuxtModule, createResolver, addPlugin, addComponentsDir, addImportsDir } from '@nuxt/kit';
|
|
2
2
|
import { defu } from 'defu';
|
|
3
3
|
|
|
4
4
|
const name = "nuxt-yandex-metrika";
|
|
5
|
-
const version = "1.0
|
|
5
|
+
const version = "1.1.0";
|
|
6
6
|
|
|
7
7
|
const module = defineNuxtModule({
|
|
8
8
|
meta: {
|
|
@@ -19,6 +19,7 @@ const module = defineNuxtModule({
|
|
|
19
19
|
debug: process.env.NODE_ENV !== "production",
|
|
20
20
|
delay: 0,
|
|
21
21
|
cdn: false,
|
|
22
|
+
verification: null,
|
|
22
23
|
options: {}
|
|
23
24
|
},
|
|
24
25
|
setup(options, nuxt) {
|
|
@@ -31,9 +32,8 @@ const module = defineNuxtModule({
|
|
|
31
32
|
mode: "all",
|
|
32
33
|
src: resolver.resolve("./runtime/plugin")
|
|
33
34
|
});
|
|
34
|
-
void
|
|
35
|
-
|
|
36
|
-
filePath: resolver.resolve("./runtime/yandex-metrika-informer.vue")
|
|
35
|
+
void addComponentsDir({
|
|
36
|
+
path: resolver.resolve("runtime/components")
|
|
37
37
|
});
|
|
38
38
|
addImportsDir(resolver.resolve("runtime/composables"));
|
|
39
39
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { useYandexMetrika } from "./composables/useYandexMetrika";
|
|
3
|
+
const { id } = useYandexMetrika();
|
|
4
|
+
</script>
|
|
5
|
+
|
|
6
|
+
<template>
|
|
7
|
+
<!-- Yandex.Metrika informer -->
|
|
8
|
+
<a
|
|
9
|
+
:href="`https://metrika.yandex.ru/stat/?id=${id}&from=informer`"
|
|
10
|
+
target="_blank"
|
|
11
|
+
rel="nofollow"
|
|
12
|
+
><img
|
|
13
|
+
:src="`https://informer.yandex.ru/informer/${id}/3_1_FFFFFFFF_EFEFEFFF_0_pageviews`"
|
|
14
|
+
style="width: 88px; height: 31px; border: 0"
|
|
15
|
+
alt="Яндекс.Метрика"
|
|
16
|
+
title="Яндекс.Метрика: данные за сегодня (просмотры, визиты и уникальные посетители)"
|
|
17
|
+
class="ym-advanced-informer"
|
|
18
|
+
:data-cid="id"
|
|
19
|
+
data-lang="ru"
|
|
20
|
+
/></a>
|
|
21
|
+
<!-- /Yandex.Metrika informer -->
|
|
22
|
+
</template>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { useYandexMetrika } from "../composables/useYandexMetrika";
|
|
3
|
+
import chalk from "chalk";
|
|
4
|
+
|
|
5
|
+
const { verification } = useYandexMetrika();
|
|
6
|
+
|
|
7
|
+
if (!verification) {
|
|
8
|
+
console.error(
|
|
9
|
+
`${chalk.bgRed(chalk.black("[yandex-metrika]"))} ${chalk.red(
|
|
10
|
+
"Verification key not found",
|
|
11
|
+
)}`,
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<template>
|
|
17
|
+
<Meta
|
|
18
|
+
v-if="verification"
|
|
19
|
+
name="yandex-verification"
|
|
20
|
+
:content="verification"
|
|
21
|
+
/>
|
|
22
|
+
</template>
|
|
23
|
+
|
|
24
|
+
<style scoped></style>
|
package/dist/runtime/plugin.mjs
CHANGED
|
@@ -9,7 +9,14 @@ export default defineNuxtPlugin({
|
|
|
9
9
|
parallel: true,
|
|
10
10
|
setup() {
|
|
11
11
|
const config = useRuntimeConfig().public.yandexMetrika;
|
|
12
|
-
const {
|
|
12
|
+
const {
|
|
13
|
+
id,
|
|
14
|
+
cdn = false,
|
|
15
|
+
delay = 0,
|
|
16
|
+
debug,
|
|
17
|
+
verification = null,
|
|
18
|
+
options = {}
|
|
19
|
+
} = config;
|
|
13
20
|
if (!debug) {
|
|
14
21
|
useHead({
|
|
15
22
|
noscript: [
|
|
@@ -19,8 +26,6 @@ export default defineNuxtPlugin({
|
|
|
19
26
|
]
|
|
20
27
|
});
|
|
21
28
|
}
|
|
22
|
-
function useYandexMetrikaHead() {
|
|
23
|
-
}
|
|
24
29
|
if (debug || delay) {
|
|
25
30
|
useHead({
|
|
26
31
|
script: [
|
|
@@ -55,6 +60,7 @@ export default defineNuxtPlugin({
|
|
|
55
60
|
}
|
|
56
61
|
const yandexMetrika = new YandexMetrika(id);
|
|
57
62
|
yandexMetrika.debug = debug;
|
|
63
|
+
yandexMetrika.verification = verification;
|
|
58
64
|
if (process.client) {
|
|
59
65
|
let ready = false;
|
|
60
66
|
const router = useRouter();
|
|
@@ -6,6 +6,8 @@ export declare class YandexMetrika implements Events {
|
|
|
6
6
|
constructor(id: string);
|
|
7
7
|
get debug(): boolean;
|
|
8
8
|
set debug(value: boolean);
|
|
9
|
+
get verification(): string | null;
|
|
10
|
+
set verification(value: string | null);
|
|
9
11
|
get id(): string;
|
|
10
12
|
init(options?: InitParameters): void;
|
|
11
13
|
addFileExtension(extensions?: string | string[]): void;
|
|
@@ -6,6 +6,7 @@ export * from "./types.mjs";
|
|
|
6
6
|
export class YandexMetrika {
|
|
7
7
|
#id;
|
|
8
8
|
#debug = false;
|
|
9
|
+
#verification = null;
|
|
9
10
|
static src(cdn = false) {
|
|
10
11
|
return cdn ? "https://cdn.jsdelivr.net/npm/yandex-metrica-watch/tag.js" : "https://mc.yandex.ru/metrika/tag.js";
|
|
11
12
|
}
|
|
@@ -18,6 +19,12 @@ export class YandexMetrika {
|
|
|
18
19
|
set debug(value) {
|
|
19
20
|
this.#debug = value;
|
|
20
21
|
}
|
|
22
|
+
get verification() {
|
|
23
|
+
return this.#verification;
|
|
24
|
+
}
|
|
25
|
+
set verification(value) {
|
|
26
|
+
this.#verification = value;
|
|
27
|
+
}
|
|
21
28
|
get id() {
|
|
22
29
|
return this.#id;
|
|
23
30
|
}
|
|
@@ -63,9 +70,7 @@ export class YandexMetrika {
|
|
|
63
70
|
#call(type, ...args) {
|
|
64
71
|
if (this.#debug) {
|
|
65
72
|
console.debug(
|
|
66
|
-
`${chalk.bgGreen(chalk.black("[yandex
|
|
67
|
-
type
|
|
68
|
-
)}`,
|
|
73
|
+
`${chalk.bgGreen(chalk.black("[yandex-metrika]"))} ${chalk.blue(type)}`,
|
|
69
74
|
...args
|
|
70
75
|
);
|
|
71
76
|
}
|
package/package.json
CHANGED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { useYandexMetrika } from "./composables/useYandexMetrika";
|
|
3
|
-
const { id } = useYandexMetrika();
|
|
4
|
-
</script>
|
|
5
|
-
|
|
6
|
-
<template>
|
|
7
|
-
<!-- Yandex.Metrika informer -->
|
|
8
|
-
<a
|
|
9
|
-
:href="`https://metrika.yandex.ru/stat/?id=${id}&from=informer`"
|
|
10
|
-
target="_blank"
|
|
11
|
-
rel="nofollow"
|
|
12
|
-
><img
|
|
13
|
-
:src="`https://informer.yandex.ru/informer/${id}/3_1_FFFFFFFF_EFEFEFFF_0_pageviews`"
|
|
14
|
-
style="width: 88px; height: 31px; border: 0"
|
|
15
|
-
alt="Яндекс.Метрика"
|
|
16
|
-
title="Яндекс.Метрика: данные за сегодня (просмотры, визиты и уникальные посетители)"
|
|
17
|
-
class="ym-advanced-informer"
|
|
18
|
-
:data-cid="id"
|
|
19
|
-
data-lang="ru"
|
|
20
|
-
></a>
|
|
21
|
-
<!-- /Yandex.Metrika informer -->
|
|
22
|
-
</template>
|