Browse Source

set page names dynamically

AykutSarac 2 years ago
parent
commit
76615cc34a
2 changed files with 12 additions and 2 deletions
  1. 6 0
      src/containers/Editor/BottomBar.tsx
  2. 6 2
      src/pages/sign-in.tsx

+ 6 - 0
src/containers/Editor/BottomBar.tsx

@@ -1,4 +1,5 @@
 import React from "react";
+import Head from "next/head";
 import { useRouter } from "next/router";
 import toast from "react-hot-toast";
 import {
@@ -140,6 +141,11 @@ export const BottomBar = () => {
 
   return (
     <StyledBottomBar>
+      {data?.name && (
+        <Head>
+          <title>{data.name} | JSON Crack</title>
+        </Head>
+      )}
       <StyledLeft>
         <StyledBottomBarItem onClick={handleLoginClick}>
           <VscAccount />

+ 6 - 2
src/pages/sign-in.tsx

@@ -1,4 +1,5 @@
 import React from "react";
+import Head from "next/head";
 import Link from "next/link";
 import { useRouter } from "next/router";
 import { AiOutlineGithub, AiOutlineGoogle } from "react-icons/ai";
@@ -35,8 +36,8 @@ const SignIn = () => {
   const isAuthenticated = useUser(state => state.isAuthenticated);
 
   React.useEffect(() => {
-      if (!isReady) checkSession();
-      if (isAuthenticated) replace("/editor");
+    if (!isReady) checkSession();
+    if (isAuthenticated) replace("/editor");
   }, [isReady, isAuthenticated, replace, checkSession]);
 
   const handleLoginClick = (provider: "github" | "google") => {
@@ -45,6 +46,9 @@ const SignIn = () => {
 
   return (
     <>
+      <Head>
+        <title>Sign In | JSON Crack</title>
+      </Head>
       <Navbar />
       <StyledPageWrapper>
         <StyledHeroSection>