diff --git a/src/components/blog/index.jsx b/src/components/blog/index.jsx
index 16f4938..3763729 100644
--- a/src/components/blog/index.jsx
+++ b/src/components/blog/index.jsx
@@ -7,13 +7,7 @@ import { getDevPost, getMediumPost } from '@arifszn/blog-js';
import { formatDistance } from 'date-fns';
const displaySection = (blog) => {
- if (
- typeof blog !== 'undefined' &&
- typeof blog.source !== 'undefined' &&
- typeof blog.username !== 'undefined' &&
- blog.source &&
- blog.username
- ) {
+ if (blog?.source && blog?.username) {
return true;
} else {
return false;
@@ -121,8 +115,7 @@ const Blog = ({ loading, blog, googleAnalytics }) => {
console.error(error);
}
- typeof window !== 'undefined' &&
- window.open(article.link, '_blank');
+ window?.open(article.link, '_blank');
}}
>
diff --git a/src/components/details/index.jsx b/src/components/details/index.jsx
index 753667f..2008240 100644
--- a/src/components/details/index.jsx
+++ b/src/components/details/index.jsx
@@ -105,7 +105,7 @@ const Details = ({ profile, loading, social, github }) => {
value={github.username}
link={`https://github.com/${github.username}`}
/>
- {typeof social.twitter !== 'undefined' && social.twitter && (
+ {social?.twitter && (
}
title="Twitter:"
@@ -113,7 +113,7 @@ const Details = ({ profile, loading, social, github }) => {
link={`https://twitter.com/${social.twitter}`}
/>
)}
- {typeof social.linkedin !== 'undefined' && social.linkedin && (
+ {social?.linkedin && (
}
title="LinkedIn:"
@@ -121,7 +121,7 @@ const Details = ({ profile, loading, social, github }) => {
link={`https://www.linkedin.com/in/${social.linkedin}`}
/>
)}
- {typeof social.dribbble !== 'undefined' && social.dribbble && (
+ {social?.dribbble && (
}
title="Dribbble:"
@@ -129,7 +129,7 @@ const Details = ({ profile, loading, social, github }) => {
link={`https://dribbble.com/${social.dribbble}`}
/>
)}
- {typeof social.behance !== 'undefined' && social.behance && (
+ {social?.behance && (
}
title="Behance:"
@@ -137,7 +137,7 @@ const Details = ({ profile, loading, social, github }) => {
link={`https://www.behance.net/${social.behance}`}
/>
)}
- {typeof social.facebook !== 'undefined' && social.facebook && (
+ {social?.facebook && (
}
title="Facebook:"
@@ -145,7 +145,7 @@ const Details = ({ profile, loading, social, github }) => {
link={`https://www.facebook.com/${social.facebook}`}
/>
)}
- {typeof social.instagram !== 'undefined' && social.instagram && (
+ {social?.instagram && (
}
title="Instagram:"
@@ -153,7 +153,7 @@ const Details = ({ profile, loading, social, github }) => {
link={`https://www.instagram.com/${social.instagram}`}
/>
)}
- {typeof social.medium !== 'undefined' && social.medium && (
+ {social?.medium && (
}
title="Medium:"
@@ -161,7 +161,7 @@ const Details = ({ profile, loading, social, github }) => {
link={`https://medium.com/@${social.medium}`}
/>
)}
- {typeof social.dev !== 'undefined' && social.dev && (
+ {social?.dev && (
}
title="Dev:"
@@ -169,7 +169,7 @@ const Details = ({ profile, loading, social, github }) => {
link={`https://dev.to/${social.dev}`}
/>
)}
- {typeof social.website !== 'undefined' && social.website && (
+ {social?.website && (
}
title="Website:"
@@ -177,7 +177,7 @@ const Details = ({ profile, loading, social, github }) => {
link={social.website}
/>
)}
- {typeof social.phone !== 'undefined' && social.phone && (
+ {social?.phone && (
}
title="Phone:"
@@ -185,7 +185,7 @@ const Details = ({ profile, loading, social, github }) => {
link={`tel:${social.phone}`}
/>
)}
- {typeof social.email !== 'undefined' && social.email && (
+ {social?.email && (
}
title="Email:"
diff --git a/src/components/education/index.jsx b/src/components/education/index.jsx
index a746d69..a9cd0e8 100644
--- a/src/components/education/index.jsx
+++ b/src/components/education/index.jsx
@@ -40,7 +40,7 @@ const Education = ({ loading, education }) => {
return (
<>
- {typeof education !== 'undefined' && education.length !== 0 && (
+ {education?.length !== 0 && (
diff --git a/src/components/experience/index.jsx b/src/components/experience/index.jsx
index 334a4b8..8fafefd 100644
--- a/src/components/experience/index.jsx
+++ b/src/components/experience/index.jsx
@@ -40,7 +40,7 @@ const Experience = ({ experiences, loading }) => {
return (
<>
- {typeof experiences !== 'undefined' && experiences.length !== 0 && (
+ {experiences?.length !== 0 && (
diff --git a/src/components/head-tag-editor/index.jsx b/src/components/head-tag-editor/index.jsx
index bd9f767..f7dd12d 100644
--- a/src/components/head-tag-editor/index.jsx
+++ b/src/components/head-tag-editor/index.jsx
@@ -1,7 +1,7 @@
import { Fragment } from 'react';
import { Helmet } from 'react-helmet-async';
import PropTypes from 'prop-types';
-import { isThemeDarkish } from '../../helpers/utils';
+import { isDarkishTheme } from '../../helpers/utils';
const HeadTagEditor = ({ profile, theme, googleAnalytics, social }) => {
return (
@@ -25,7 +25,7 @@ const HeadTagEditor = ({ profile, theme, googleAnalytics, social }) => {
Portfolio of {profile.name}
@@ -34,12 +34,7 @@ const HeadTagEditor = ({ profile, theme, googleAnalytics, social }) => {
-
+
diff --git a/src/components/project/index.jsx b/src/components/project/index.jsx
index 2154e71..44e23f1 100644
--- a/src/components/project/index.jsx
+++ b/src/components/project/index.jsx
@@ -72,7 +72,7 @@ const Project = ({ repo, loading, github, googleAnalytics }) => {
console.error(error);
}
- typeof window !== 'undefined' && window.open(item.html_url, '_blank');
+ window?.open(item.html_url, '_blank');
}}
>
diff --git a/src/components/skill/index.jsx b/src/components/skill/index.jsx
index 3ed90f9..7a85a4f 100644
--- a/src/components/skill/index.jsx
+++ b/src/components/skill/index.jsx
@@ -17,7 +17,7 @@ const Skill = ({ loading, skills }) => {
return (
<>
- {typeof skills !== 'undefined' && skills.length !== 0 && (
+ {skills?.length !== 0 && (
diff --git a/src/helpers/utils.jsx b/src/helpers/utils.jsx
index dd8bf05..5c58d0b 100644
--- a/src/helpers/utils.jsx
+++ b/src/helpers/utils.jsx
@@ -76,7 +76,7 @@ export const ga = {
},
};
-export const isThemeDarkish = (theme) => {
+export const isDarkishTheme = (theme) => {
return ['dark', 'halloween', 'forest', 'black', 'luxury', 'dracula'].includes(
theme
);
@@ -136,11 +136,11 @@ export const sanitizeConfig = (config) => {
return {
github: {
- username: config.github.username,
- sortBy: config.github.sortBy || 'stars',
- limit: config.github.limit || 8,
+ username: config?.github?.username || '',
+ sortBy: config?.github?.sortBy || 'stars',
+ limit: config?.github?.limit || 8,
exclude: {
- forks: config?.github?.exclude?.forks,
+ forks: config?.github?.exclude?.forks || false,
projects: config?.github?.exclude?.projects || [],
},
},
@@ -174,8 +174,9 @@ export const sanitizeConfig = (config) => {
},
themeConfig: {
defaultTheme: config?.themeConfig?.defaultTheme || themes[0],
- disableSwitch: config?.themeConfig?.disableSwitch,
- respectPrefersColorScheme: config?.themeConfig?.respectPrefersColorScheme,
+ disableSwitch: config?.themeConfig?.disableSwitch || false,
+ respectPrefersColorScheme:
+ config?.themeConfig?.respectPrefersColorScheme || false,
themes: themes,
customTheme: customTheme,
},