Fix scrolling bug in content pages

This commit is contained in:
Hazem Krimi
2021-01-19 00:49:23 +01:00
parent 964666bdc7
commit eec6c529df
2 changed files with 10 additions and 2 deletions
+5 -1
View File
@@ -1,4 +1,4 @@
import { FC } from 'react';
import { FC, useEffect } from 'react';
import { getBlogPostsSlugs, getBlogPostdata } from '../../lib/blog';
import { useRouter } from 'next/router';
import { MdxRemote } from 'next-mdx-remote/types';
@@ -110,6 +110,10 @@ const BlogPost: FC<Props> = ({ source, frontMatter }) => {
const content = hydrate(source, { components });
const router = useRouter();
useEffect(() => {
window.scrollTo(0, 0);
}, []);
return (
<>
<Head>
+5 -1
View File
@@ -1,4 +1,4 @@
import { FC } from 'react';
import { FC, useEffect } from 'react';
import { getPortfolioPorjectsSlugs, getPortfolioProjectdata } from '../../lib/portfolio';
import { useRouter } from 'next/router';
import { MdxRemote } from 'next-mdx-remote/types';
@@ -101,6 +101,10 @@ const PortfolioProject: FC<Props> = ({ source, frontMatter }) => {
const content = hydrate(source, { components });
const router = useRouter();
useEffect(() => {
window.scrollTo(0, 0);
}, []);
return (
<>
<Head>