1
Fork 0
mirror of https://github.com/Steffo99/todocolors.git synced 2024-11-25 17:54:18 +00:00

Set board page title from board title

This commit is contained in:
Steffo 2023-08-16 15:38:58 +02:00
parent 50d765d3bd
commit 3544aa7315
Signed by: steffo
GPG key ID: 2A24051445686895
3 changed files with 15 additions and 8 deletions

View file

@ -0,0 +1,8 @@
import {useEffect} from "react"
export function usePageTitleSetter(title: string) {
useEffect(() => {
document.title = title
}, [title])
}

View file

@ -1,12 +1,19 @@
import {usePageTitleSetter} from "@/app/(utils)/usePageTitleSetter"
import {useBoardConsumer} from "@/app/[lang]/board/[board]/(layout)/(contextBoard)"
import style from "@/app/[lang]/board/[board]/(page)/(header)/BoardHeaderTitle.module.css"
import {useBoardMetadataEditor} from "@/app/[lang]/board/[board]/(page)/useBoardMetadataEditor"
import cn from "classnames"
import {useMemo} from "react"
export function BoardHeaderTitle({className, editorHook}: {className?: string, editorHook: ReturnType<typeof useBoardMetadataEditor>}) {
const {isReady, boardState: {title: titleFromState}} = useBoardConsumer()
const pageTitle = useMemo(() => {
return titleFromState.length > 0 ? `${titleFromState} - Todocolors` : "Todocolors"
}, [titleFromState])
usePageTitleSetter(pageTitle)
if(!isReady) return null;
let contents;

View file

@ -1,12 +1,4 @@
import {TaskEditor} from "@/app/[lang]/board/[board]/(page)/(edit)/TaskEditor"
import {BoardPage} from "@/app/[lang]/board/[board]/(page)/BoardPage"
import {useBoardLayoutEditor} from "@/app/[lang]/board/[board]/(page)/useBoardLayoutEditor"
import {useBoardMetadataEditor} from "@/app/[lang]/board/[board]/(page)/useBoardMetadataEditor"
import {BoardMain} from "@/app/[lang]/board/[board]/(page)/(view)/BoardMain"
import {BoardHeader} from "@/app/[lang]/board/[board]/(page)/(header)/BoardHeader"
import {useTaskEditor} from "@/app/[lang]/board/[board]/(page)/useTaskEditor"
import {Metadata} from "next"
import style from "./page.module.css"
export default function page({params: {lang}}: {params: {lang: string}}) {