mirror of
https://github.com/NohamR/gitprofile.git
synced 2026-05-25 12:27:17 +00:00
Support SSR
This commit is contained in:
@@ -121,7 +121,8 @@ const Blog = ({ loading, blog, googleAnalytics }) => {
|
|||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
window.open(article.link, '_blank');
|
typeof window !== 'undefined' &&
|
||||||
|
window.open(article.link, '_blank');
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div className="p-8 h-full w-full">
|
<div className="p-8 h-full w-full">
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ const Project = ({ repo, loading, github, googleAnalytics }) => {
|
|||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
window.open(item.html_url, '_blank');
|
typeof window !== 'undefined' && window.open(item.html_url, '_blank');
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div className="flex justify-between flex-col p-8 h-full w-full">
|
<div className="flex justify-between flex-col p-8 h-full w-full">
|
||||||
|
|||||||
@@ -17,7 +17,8 @@ export const getInitialTheme = (themeConfig) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (themeConfig.respectPrefersColorScheme && !themeConfig.disableSwitch) {
|
if (themeConfig.respectPrefersColorScheme && !themeConfig.disableSwitch) {
|
||||||
return window.matchMedia('(prefers-color-scheme: dark)').matches
|
return typeof window !== 'undefined' &&
|
||||||
|
window.matchMedia('(prefers-color-scheme: dark)').matches
|
||||||
? 'dark'
|
? 'dark'
|
||||||
: themeConfig.defaultTheme;
|
: themeConfig.defaultTheme;
|
||||||
}
|
}
|
||||||
@@ -57,8 +58,10 @@ export const ga = {
|
|||||||
// initialize google analytic
|
// initialize google analytic
|
||||||
initialize: (id) => {
|
initialize: (id) => {
|
||||||
try {
|
try {
|
||||||
window.gtag('js', new Date());
|
if (typeof window !== 'undefined') {
|
||||||
window.gtag('config', id);
|
window.gtag('js', new Date());
|
||||||
|
window.gtag('config', id);
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
@@ -66,7 +69,7 @@ export const ga = {
|
|||||||
// log specific events happening
|
// log specific events happening
|
||||||
event: ({ action, params }) => {
|
event: ({ action, params }) => {
|
||||||
try {
|
try {
|
||||||
window.gtag('event', action, params);
|
typeof window !== 'undefined' && window.gtag('event', action, params);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user