Skip to content

Commit

Permalink
fix BaiDuAnalytics
Browse files Browse the repository at this point in the history
  • Loading branch information
zjy365 committed Jul 31, 2024
1 parent b87122c commit 989c8cd
Showing 1 changed file with 8 additions and 18 deletions.
26 changes: 8 additions & 18 deletions projects/fastgpt/app/BaiDuAnalytics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,16 @@
import Script from 'next/script';

const BaiDuAnalytics = () => {
const key = process.env.NEXT_PUBLIC_BAIDU_TONGJI;

return (
<>
{process.env.NEXT_PUBLIC_BAIDU_TONGJI ? (
<>
<Script
id="baidu-tongji"
strategy="afterInteractive"
dangerouslySetInnerHTML={{
__html: `
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?${process.env.NEXT_PUBLIC_BAIDU_TONGJI}";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
`
}}
/>
</>
{key ? (
<Script
id="baidu-tongji"
strategy="afterInteractive"
src={`https://hm.baidu.com/hm.js?${key}`}
/>
) : (
<></>
)}
Expand Down

0 comments on commit 989c8cd

Please sign in to comment.