From 89068487a9fa99a0b37a3c6e9e6ab44189ba099a Mon Sep 17 00:00:00 2001 From: liuhy Date: Fri, 3 Jan 2025 18:23:44 +0800 Subject: [PATCH] [type:feature] modify to matomo plugin --- home/docusaurus.config.js | 8 +++++++- home/package.json | 5 +++-- home/src/pages/components/Matomo.js | 22 ---------------------- 3 files changed, 10 insertions(+), 25 deletions(-) delete mode 100644 home/src/pages/components/Matomo.js diff --git a/home/docusaurus.config.js b/home/docusaurus.config.js index 80e273d47d3..73f2657ea2b 100644 --- a/home/docusaurus.config.js +++ b/home/docusaurus.config.js @@ -22,12 +22,17 @@ module.exports = { repoUrl, cdnUrl, }, - clientModules: [path.resolve(__dirname, './src/pages/components/Matomo.js')], i18n: { defaultLocale: 'en', locales: ['zh-cn', 'en'], }, themeConfig: { + matomo: { + matomoUrl: 'https://analytics.apache.org/', + siteId: 'ID', + phpLoader: 'matomo.php', + jsLoader: 'matomo.js', + }, image: '/img/hertzbeat-logo.svg', liveCodeBlock: { playgroundPosition: 'bottom', @@ -345,6 +350,7 @@ module.exports = { fromExtensions: ['html'], }, ], + 'docusaurus-plugin-matomo', '@docusaurus/plugin-ideal-image', [ '@docusaurus/plugin-pwa', diff --git a/home/package.json b/home/package.json index e503487cca5..ddf065f8459 100644 --- a/home/package.json +++ b/home/package.json @@ -32,7 +32,9 @@ "aos": "^2.3.4", "clsx": "1.2.1", "color": "3.2.1", + "docusaurus-plugin-matomo": "^0.0.8", "file-loader": "6.2.0", + "markdownlint-cli2": "^0.13.0", "react": "17.0.2", "react-dom": "17.0.2", "react-slick": "0.29.0", @@ -41,8 +43,7 @@ "swiper": "7.4.1", "url-loader": "4.1.1", "workbox-routing": "6.5.3", - "workbox-strategies": "6.5.3", - "markdownlint-cli2": "^0.13.0" + "workbox-strategies": "6.5.3" }, "browserslist": { "production": [ diff --git a/home/src/pages/components/Matomo.js b/home/src/pages/components/Matomo.js deleted file mode 100644 index bc9e764fb17..00000000000 --- a/home/src/pages/components/Matomo.js +++ /dev/null @@ -1,22 +0,0 @@ -import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment'; - -if (ExecutionEnvironment.canUseDOM) { - /* Matomo */ - console.log('Matomo is enabled'); - var _paq = window._paq = window._paq || []; - /* tracker methods like "setCustomDimension" should be called before "trackPageView" */ - _paq.push(['trackPageView']); - _paq.push(['enableLinkTracking']); - (function() { - var u="https://analytics.apache.org/"; - _paq.push(['setTrackerUrl', u+'matomo.php']); - _paq.push(['setSiteId', '25']); - var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; - g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s); - })(); - /* End Matomo Code */ -} - -export default function Matomo() { - return this; -} \ No newline at end of file