@docusaurus/plugin-google-tag-manager 3.4.0 → 3.5.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/lib/index.d.ts +1 -1
- package/lib/index.js +5 -7
- package/package.json +5 -5
- package/src/index.ts +5 -6
package/lib/index.d.ts
CHANGED
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import type { LoadContext, Plugin, OptionValidationContext } from '@docusaurus/types';
|
|
8
8
|
import type { PluginOptions, Options } from './options';
|
|
9
|
-
export default function pluginGoogleAnalytics(context: LoadContext, options: PluginOptions): Plugin;
|
|
9
|
+
export default function pluginGoogleAnalytics(context: LoadContext, options: PluginOptions): Plugin | null;
|
|
10
10
|
export declare function validateOptions({ validate, options, }: OptionValidationContext<Options, PluginOptions>): PluginOptions;
|
|
11
11
|
export type { PluginOptions, Options };
|
package/lib/index.js
CHANGED
|
@@ -6,20 +6,20 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
9
|
+
exports.default = pluginGoogleAnalytics;
|
|
10
|
+
exports.validateOptions = validateOptions;
|
|
10
11
|
const utils_validation_1 = require("@docusaurus/utils-validation");
|
|
11
12
|
function pluginGoogleAnalytics(context, options) {
|
|
13
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
12
16
|
const { containerId } = options;
|
|
13
|
-
const isProd = process.env.NODE_ENV === 'production';
|
|
14
17
|
return {
|
|
15
18
|
name: 'docusaurus-plugin-google-tag-manager',
|
|
16
19
|
contentLoaded({ actions }) {
|
|
17
20
|
actions.setGlobalData(options);
|
|
18
21
|
},
|
|
19
22
|
injectHtmlTags() {
|
|
20
|
-
if (!isProd) {
|
|
21
|
-
return {};
|
|
22
|
-
}
|
|
23
23
|
return {
|
|
24
24
|
preBodyTags: [
|
|
25
25
|
{
|
|
@@ -52,11 +52,9 @@ j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
|
|
|
52
52
|
},
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
|
-
exports.default = pluginGoogleAnalytics;
|
|
56
55
|
const pluginOptionsSchema = utils_validation_1.Joi.object({
|
|
57
56
|
containerId: utils_validation_1.Joi.string().required(),
|
|
58
57
|
});
|
|
59
58
|
function validateOptions({ validate, options, }) {
|
|
60
59
|
return validate(pluginOptionsSchema, options);
|
|
61
60
|
}
|
|
62
|
-
exports.validateOptions = validateOptions;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/plugin-google-tag-manager",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.0",
|
|
4
4
|
"description": "Google Tag Manager (gtm.js) plugin for Docusaurus.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
},
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@docusaurus/core": "3.
|
|
22
|
-
"@docusaurus/types": "3.
|
|
23
|
-
"@docusaurus/utils-validation": "3.
|
|
21
|
+
"@docusaurus/core": "3.5.0",
|
|
22
|
+
"@docusaurus/types": "3.5.0",
|
|
23
|
+
"@docusaurus/utils-validation": "3.5.0",
|
|
24
24
|
"tslib": "^2.6.0"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
@@ -30,5 +30,5 @@
|
|
|
30
30
|
"engines": {
|
|
31
31
|
"node": ">=18.0"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "cb5829f3c34b26d798b869e38ee25073488140bd"
|
|
34
34
|
}
|
package/src/index.ts
CHANGED
|
@@ -16,10 +16,12 @@ import type {PluginOptions, Options} from './options';
|
|
|
16
16
|
export default function pluginGoogleAnalytics(
|
|
17
17
|
context: LoadContext,
|
|
18
18
|
options: PluginOptions,
|
|
19
|
-
): Plugin {
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
): Plugin | null {
|
|
20
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
22
23
|
|
|
24
|
+
const {containerId} = options;
|
|
23
25
|
return {
|
|
24
26
|
name: 'docusaurus-plugin-google-tag-manager',
|
|
25
27
|
|
|
@@ -28,9 +30,6 @@ export default function pluginGoogleAnalytics(
|
|
|
28
30
|
},
|
|
29
31
|
|
|
30
32
|
injectHtmlTags() {
|
|
31
|
-
if (!isProd) {
|
|
32
|
-
return {};
|
|
33
|
-
}
|
|
34
33
|
return {
|
|
35
34
|
preBodyTags: [
|
|
36
35
|
{
|