diff --git a/packages/docusaurus-plugin-google-analytics/src/index.ts b/packages/docusaurus-plugin-google-analytics/src/index.ts index 086b22c0d755..083a1ff7f42a 100644 --- a/packages/docusaurus-plugin-google-analytics/src/index.ts +++ b/packages/docusaurus-plugin-google-analytics/src/index.ts @@ -6,7 +6,7 @@ */ import path from 'path'; -import type {LoadContext, Plugin} from '@docusaurus/types'; +import type {LoadContext, Plugin, HtmlTags} from '@docusaurus/types'; import type {ThemeConfig} from '@docusaurus/plugin-google-analytics'; export default function pluginGoogleAnalytics(context: LoadContext): Plugin { @@ -43,7 +43,7 @@ export default function pluginGoogleAnalytics(context: LoadContext): Plugin { if (!isProd) { return {}; } - const HTMLTags = { + return { headTags: [ { tagName: 'link', @@ -69,9 +69,8 @@ export default function pluginGoogleAnalytics(context: LoadContext): Plugin { src: 'https://www.google-analytics.com/analytics.js', }, }, - ], + ] as HtmlTags, }; - return HTMLTags; }, }; } diff --git a/packages/docusaurus-plugin-google-gtag/src/index.ts b/packages/docusaurus-plugin-google-gtag/src/index.ts index 88a9a5aad779..09a4d467e591 100644 --- a/packages/docusaurus-plugin-google-gtag/src/index.ts +++ b/packages/docusaurus-plugin-google-gtag/src/index.ts @@ -6,7 +6,7 @@ */ import path from 'path'; -import type {LoadContext, Plugin} from '@docusaurus/types'; +import type {LoadContext, Plugin, HtmlTags} from '@docusaurus/types'; import type {ThemeConfig} from '@docusaurus/plugin-google-gtag'; export default function pluginGoogleGtag(context: LoadContext): Plugin { @@ -43,7 +43,7 @@ export default function pluginGoogleGtag(context: LoadContext): Plugin { if (!isProd) { return {}; } - const HTMLTags = { + return { // Gtag includes GA by default, so we also preconnect to google-analytics. headTags: [ { @@ -78,9 +78,8 @@ export default function pluginGoogleGtag(context: LoadContext): Plugin { anonymizeIP ? "'anonymize_ip': true" : '' } });`, }, - ], + ] as HtmlTags, }; - return HTMLTags; }, }; }