mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
[WEB-1574] chore: page head (#4773)
* chore: page head component refactor * chore: page head component refactor
This commit is contained in:
parent
8ccd37d777
commit
f4ceaaf01c
1
packages/ui/src/hooks/index.ts
Normal file
1
packages/ui/src/hooks/index.ts
Normal file
@ -0,0 +1 @@
|
||||
export * from "./use-page-title";
|
13
packages/ui/src/hooks/use-page-title.tsx
Normal file
13
packages/ui/src/hooks/use-page-title.tsx
Normal 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]);
|
||||
};
|
@ -17,3 +17,4 @@ export * from "./drag-handle";
|
||||
export * from "./typography";
|
||||
export * from "./drop-indicator";
|
||||
export * from "./sortable";
|
||||
export * from "./hooks";
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -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;
|
Loading…
Reference in New Issue
Block a user