forked from craigary/nobelium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScripts.js
48 lines (46 loc) · 1.54 KB
/
Scripts.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import Script from 'next/script'
import BLOG from '@/blog.config'
const Scripts = () => (
<>
{BLOG.analytics && BLOG.analytics.provider === 'ackee' && (
<Script
src={BLOG.analytics.ackeeConfig.tracker}
data-ackee-server={BLOG.analytics.ackeeConfig.dataAckeeServer}
data-ackee-domain-id={BLOG.analytics.ackeeConfig.domainId}
/>
)}
{/* {BLOG.autoCollapsedNavBar === true && (
<Script strategy="lazyOnload">
{`var windowTop=0;
function scrollTrigger(){
let scrollS = window.scrollY;
let nav = document.querySelector('.sticky-nav');
if(scrollS >= windowTop){
nav.style.opacity = 0;
windowTop = scrollS;
}else{
nav.style.opacity = 1;
windowTop = scrollS;
}
};
window.addEventListener('scroll',scrollTrigger);`}
</Script>
)} */}
{BLOG.analytics && BLOG.analytics.provider === 'ga' && (
<>
<Script
src={`https://www.googletagmanager.com/gtag/js?id=${BLOG.analytics.gaConfig.measurementId}`}
/>
<Script strategy="lazyOnload" id="ga">
{`window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '${BLOG.analytics.gaConfig.measurementId}', {
page_path: window.location.pathname,
});`}
</Script>
</>
)}
</>
)
export default Scripts