[WEB-1574] chore: page head (#4773)

* chore: page head component refactor

* chore: page head component refactor
This commit is contained in:
Anmol Singh Bhatia 2024-06-12 13:12:08 +05:30 committed by GitHub
parent 8ccd37d777
commit f4ceaaf01c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 18 additions and 29 deletions

View File

@ -0,0 +1 @@
export * from "./use-page-title";

View File

@ -0,0 +1,13 @@
import { useEffect } from "react";
interface IUseHeadParams {
title?: string;
}
export const useHead = ({ title }: IUseHeadParams) => {
useEffect(() => {
if (title) {
document.title = title ?? "Plane | Simple, extensible, open-source project management tool.";
}
}, [title]);
};

View File

@ -17,3 +17,4 @@ export * from "./drag-handle";
export * from "./typography";
export * from "./drop-indicator";
export * from "./sortable";
export * from "./hooks";

View File

@ -1,4 +1,4 @@
import Head from "next/head";
import { useHead } from "@plane/ui";
type PageHeadTitleProps = {
title?: string;
@ -8,11 +8,7 @@ type PageHeadTitleProps = {
export const PageHead: React.FC<PageHeadTitleProps> = (props) => {
const { title } = props;
if (!title) return null;
useHead({ title });
return (
<Head>
<title>{title}</title>
</Head>
);
return null;
};

View File

@ -1,22 +0,0 @@
import { useEffect } from "react";
import Head from "next/head";
interface IUseHeadParams {
title?: string;
}
const useHead = ({ title }: IUseHeadParams) => {
useEffect(() => {
if (title) {
document.title = title;
}
}, [title]);
return (
<Head>
<title>{title || "Plane | Simple, extensible, open-source project management tool."}</title>
</Head>
);
};
export default useHead;