Skip to content

Commit

Permalink
Refactor head
Browse files Browse the repository at this point in the history
  • Loading branch information
amaury1093 committed Dec 21, 2023
1 parent d862ec8 commit 7d45d3f
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 62 deletions.
19 changes: 0 additions & 19 deletions src/app/global-error.tsx

This file was deleted.

17 changes: 0 additions & 17 deletions src/app/layout.tsx

This file was deleted.

19 changes: 19 additions & 0 deletions src/components/Crisp.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */

import { useUser } from "@/util/useUser";
import { useRouter } from "next/router";
import { useEffect } from "react";

export default function Crisp(): null {
const router = useRouter();
const { user } = useUser();

useEffect(() => {
// @ts-expect-error
window.CRISP_RUNTIME_CONFIG = {
locale: router.locale || "en",
};

// @ts-ignore
window.$crisp = [];
// @ts-ignore
Expand All @@ -18,5 +28,14 @@ export default function Crisp(): null {
})();
}, []);

useEffect(() => {
if (!user?.email) {
return;
}

// @ts-expect-error
window.$crisp.push(["set", "user:email", user.email]);
}, []);

return null;
}
22 changes: 0 additions & 22 deletions src/components/Head.tsx

This file was deleted.

6 changes: 4 additions & 2 deletions src/components/Layout.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, { ReactElement } from "react";

import { Footer } from "./Footer";
import { Head } from "./Head";
import { Nav } from "./Nav";
import Head from "next/head";

export interface LayoutProps {
children: React.ReactChild;
Expand All @@ -11,7 +11,9 @@ export interface LayoutProps {
export function Layout({ children }: LayoutProps): ReactElement {
return (
<>
<Head />
<Head>
<title>Reacher Dashboard</title>
</Head>
<Nav />
{children}
<Footer />
Expand Down
17 changes: 15 additions & 2 deletions src/pages/_document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { CssBaseline } from "@geist-ui/react";
import Document, {
DocumentContext,
DocumentInitialProps,
Head,
Html,
Main,
NextScript,
Head,
} from "next/document";
import React from "react";

Expand All @@ -30,7 +30,20 @@ export default class MyDocument extends Document {
render(): React.ReactElement {
return (
<Html>
<Head />
<Head>
<meta charSet="utf-8" />

<link rel="shortcut icon" href="/favicon.png" />

<link
rel="stylesheet"
href="https://unpkg.com/spectre.css/dist/spectre.min.css"
></link>
<link
rel="stylesheet"
href="https://unpkg.com/spectre.css/dist/spectre-icons.min.css"
></link>
</Head>
<body>
<Main />
<NextScript />
Expand Down

0 comments on commit 7d45d3f

Please sign in to comment.