Skip to content

Commit

Permalink
fix: preview still increment meta on first visit
Browse files Browse the repository at this point in the history
  • Loading branch information
theodorusclarence committed Mar 17, 2022
1 parent 0255faa commit b499a75
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import '@/styles/mdx.css';
import '@/styles/dracula.css';
import '@/styles/nprogress.css';

import { getFromLocalStorage } from '@/lib/helper';

import { blockDomainMeta } from '@/constants/env';

Router.events.on('routeChangeStart', nProgress.start);
Expand All @@ -23,7 +25,11 @@ function MyApp({ Component, pageProps }: AppProps) {
React.useEffect(() => {
// Don't increment views if not on main domain
if (window.location.host !== 'theodorusclarence.com' && blockDomainMeta) {
localStorage.setItem('incrementMetaFlag', 'false');
if (getFromLocalStorage('incrementMetaFlag') !== 'false') {
localStorage.setItem('incrementMetaFlag', 'false');
// reload page to make changes
window.location.reload();
}
}
}, []);

Expand Down

1 comment on commit b499a75

@vercel
Copy link

@vercel vercel bot commented on b499a75 Mar 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.