Skip to content

Commit

Permalink
Merge branch 'feature/alova@3.x' of https://github.com/alovajs/alovaj…
Browse files Browse the repository at this point in the history
  • Loading branch information
JOU-amjs committed Sep 5, 2024
2 parents b10eb27 + a9ce74a commit 60334f9
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
6 changes: 6 additions & 0 deletions docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,12 @@ const config: Config = {
{
id: '5afa4c96fca09cb386951b736ee31e56'
}
],
[
'./plugin/googleStatistics',
{
id: 'G-HYBM7B3X0N'
}
]
]
};
Expand Down
4 changes: 2 additions & 2 deletions plugin/baiduStatistics.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = async function myPlugin(_, { id }) {
export default async function (_, { id }) {
const isProd = process.env.NODE_ENV === 'production';
return {
name: 'baidu-statistics',
Expand All @@ -24,4 +24,4 @@ module.exports = async function myPlugin(_, { id }) {
};
}
};
};
}
31 changes: 31 additions & 0 deletions plugin/googleStatistics.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
export default async function (_, { id }) {
const isProd = process.env.NODE_ENV === 'production';
return {
name: 'google-statistics',
injectHtmlTags() {
if (!isProd) {
return {};
}
return {
headTags: [
{
tagName: 'script',
attributes: {
async: true,
src: `https://www.googletagmanager.com/gtag/js?id=${id}`
}
},
{
tagName: 'script',
innerHTML: `
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '${id}');
`
}
]
};
}
};
}

0 comments on commit 60334f9

Please sign in to comment.