mirror of
https://github.com/hazemKrimi/personal-website.git
synced 2026-05-01 18:00:26 +00:00
Make favicon dynamic and add og:image
This commit is contained in:
@@ -22,6 +22,8 @@ const DarkMode: FC = ({ children }) => {
|
||||
const [dark, dispatch] = useReducer(reducer, false);
|
||||
const toggle = () => {
|
||||
const root = window.document.documentElement;
|
||||
const lightFavicon = document.querySelector('link#light-favicon')!;
|
||||
const darkFavicon = document.querySelector('link#dark-favicon')!;
|
||||
|
||||
if (dark) {
|
||||
window.localStorage.setItem('theme', 'light');
|
||||
@@ -29,12 +31,14 @@ const DarkMode: FC = ({ children }) => {
|
||||
root.style.setProperty('--secondary-background', 'white');
|
||||
root.style.setProperty('--text', 'black');
|
||||
root.style.setProperty('--text-inverted', 'white');
|
||||
document.head.append(darkFavicon);
|
||||
} else {
|
||||
window.localStorage.setItem('theme', 'dark');
|
||||
root.style.setProperty('--background', '#262626');
|
||||
root.style.setProperty('--secondary-background', '#2F2F2F');
|
||||
root.style.setProperty('--text', 'white');
|
||||
root.style.setProperty('--text-inverted', 'black');
|
||||
document.head.append(lightFavicon);
|
||||
}
|
||||
|
||||
dispatch({ type: 'TOGGLE' });
|
||||
|
||||
+1
-2
@@ -40,9 +40,8 @@ const NotFound: FC = () => {
|
||||
name='description'
|
||||
content='Hazem Krimi is a Full Stack JavaScript Developer and a Software Engineering Enthusiast'
|
||||
/>
|
||||
<link rel='shortcut icon' href='favicon.ico' type='image/x-icon' />
|
||||
<link rel='canonical' href='https://hazemkrimi.tech/*' />
|
||||
<meta property='og:image' content='/logo.jpg' />
|
||||
<meta property='og:image' content='/logo.png' />
|
||||
<meta
|
||||
property='og:description'
|
||||
content='Hazem Krimi is a Full Stack JavaScript Developer and a Software Engineering Enthusiast'
|
||||
|
||||
@@ -31,6 +31,8 @@ class Doc extends Document {
|
||||
return (
|
||||
<Html>
|
||||
<Head>
|
||||
<link rel='shortcut icon' href='light-favicon.png' id='light-favicon'></link>
|
||||
<link rel='shortcut icon' href='dark-favicon.png' id='dark-favicon'></link>
|
||||
<script async src='https://www.googletagmanager.com/gtag/js?id=G-FMD81GLKS3'></script>
|
||||
<script
|
||||
dangerouslySetInnerHTML={{
|
||||
@@ -67,6 +69,8 @@ class Doc extends Document {
|
||||
(() => {
|
||||
const theme = getInitialTheme();
|
||||
const root = document.documentElement;
|
||||
const lightFavicon = document.querySelector('link#light-favicon');
|
||||
const darkFavicon = document.querySelector('link#dark-favicon');
|
||||
|
||||
root.style.setProperty('--theme', theme);
|
||||
root.style.setProperty(
|
||||
@@ -85,6 +89,7 @@ class Doc extends Document {
|
||||
'--text-inverted',
|
||||
theme === 'light' ? 'white' : 'black'
|
||||
);
|
||||
document.head.append(theme === 'light' ? darkFavicon : lightFavicon);
|
||||
})();
|
||||
`
|
||||
}}
|
||||
|
||||
+1
-2
@@ -100,9 +100,8 @@ const About: FC = () => {
|
||||
name='description'
|
||||
content='Hazem Krimi is a Full Stack JavaScript Developer and a Software Engineering Enthusiast'
|
||||
/>
|
||||
<link rel='shortcut icon' href='favicon.ico' type='image/x-icon' />
|
||||
<link rel='canonical' href='https://hazemkrimi.tech/about' />
|
||||
<meta property='og:image' content='/logo.jpg' />
|
||||
<meta property='og:image' content='/logo.png' />
|
||||
<meta
|
||||
property='og:description'
|
||||
content='Hazem Krimi is a Full Stack JavaScript Developer and a Software Engineering Enthusiast'
|
||||
|
||||
@@ -126,9 +126,8 @@ const BlogPost: FC<Props> = ({ source, frontMatter, text }) => {
|
||||
: 'Hazem Krimi is a Full Stack JavaScript Developer and a Software Engineering Enthusiast'
|
||||
}
|
||||
/>
|
||||
<link rel='shortcut icon' href='favicon.ico' type='image/x-icon' />
|
||||
<link rel='canonical' href='https://hazemkrimi.tech' />
|
||||
<meta property='og:image' content='/logo.jpg' />
|
||||
<meta property='og:image' content='/logo.png' />
|
||||
<meta
|
||||
property='og:description'
|
||||
content={
|
||||
|
||||
@@ -64,9 +64,8 @@ const Index: FC<Props> = ({ blogPosts }) => {
|
||||
name='description'
|
||||
content='Hazem Krimi is a Full Stack JavaScript Developer and a Software Engineering Enthusiast'
|
||||
/>
|
||||
<link rel='shortcut icon' href='favicon.ico' type='image/x-icon' />
|
||||
<link rel='canonical' href='https://hazemkrimi.tech/blog' />
|
||||
<meta property='og:image' content='/logo.jpg' />
|
||||
<meta property='og:image' content='/logo.png' />
|
||||
<meta
|
||||
property='og:description'
|
||||
content='Hazem Krimi is a Full Stack JavaScript Developer and a Software Engineering Enthusiast'
|
||||
|
||||
+1
-2
@@ -86,9 +86,8 @@ const Index: FC<Props> = ({ blogPosts, portfolioProjects }) => {
|
||||
name='description'
|
||||
content='Hazem Krimi is a Full Stack JavaScript Developer and a Software Engineering Enthusiast'
|
||||
/>
|
||||
<link rel='shortcut icon' href='favicon.ico' type='image/x-icon' />
|
||||
<link rel='canonical' href='https://hazemkrimi.tech' />
|
||||
<meta property='og:image' content='/logo.jpg' />
|
||||
<meta property='og:image' content='/logo.png' />
|
||||
<meta
|
||||
property='og:description'
|
||||
content='Hazem Krimi is a Full Stack JavaScript Developer and a Software Engineering Enthusiast'
|
||||
|
||||
@@ -112,9 +112,8 @@ const PortfolioProject: FC<Props> = ({ source, frontMatter }) => {
|
||||
: 'Hazem Krimi is a Full Stack JavaScript Developer and a Software Engineering Enthusiast'
|
||||
}
|
||||
/>
|
||||
<link rel='shortcut icon' href='favicon.ico' type='image/x-icon' />
|
||||
<link rel='canonical' href='https://hazemkrimi.tech' />
|
||||
<meta property='og:image' content='/logo.jpg' />
|
||||
<meta property='og:image' content='/logo.png' />
|
||||
<meta
|
||||
property='og:description'
|
||||
content={
|
||||
|
||||
@@ -63,9 +63,8 @@ const Index: FC<Props> = ({ portfolioProjects }) => {
|
||||
name='description'
|
||||
content='Hazem Krimi is a Full Stack JavaScript Developer and a Software Engineering Enthusiast'
|
||||
/>
|
||||
<link rel='shortcut icon' href='favicon.ico' type='image/x-icon' />
|
||||
<link rel='canonical' href='https://hazemkrimi.tech/portfolio' />
|
||||
<meta property='og:image' content='/logo.jpg' />
|
||||
<meta property='og:image' content='/logo.png' />
|
||||
<meta
|
||||
property='og:description'
|
||||
content='Hazem Krimi is a Full Stack JavaScript Developer and a Software Engineering Enthusiast'
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 310 B |
Binary file not shown.
|
After Width: | Height: | Size: 312 B |
Binary file not shown.
|
After Width: | Height: | Size: 18 KiB |
Reference in New Issue
Block a user