mirror of
https://github.com/Steffo99/todocolors.git
synced 2024-11-22 08:14:18 +00:00
Set board page title from board title
This commit is contained in:
parent
50d765d3bd
commit
3544aa7315
3 changed files with 15 additions and 8 deletions
8
todoblue/src/app/(utils)/usePageTitleSetter.ts
Normal file
8
todoblue/src/app/(utils)/usePageTitleSetter.ts
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
import {useEffect} from "react"
|
||||||
|
|
||||||
|
|
||||||
|
export function usePageTitleSetter(title: string) {
|
||||||
|
useEffect(() => {
|
||||||
|
document.title = title
|
||||||
|
}, [title])
|
||||||
|
}
|
|
@ -1,12 +1,19 @@
|
||||||
|
import {usePageTitleSetter} from "@/app/(utils)/usePageTitleSetter"
|
||||||
import {useBoardConsumer} from "@/app/[lang]/board/[board]/(layout)/(contextBoard)"
|
import {useBoardConsumer} from "@/app/[lang]/board/[board]/(layout)/(contextBoard)"
|
||||||
import style from "@/app/[lang]/board/[board]/(page)/(header)/BoardHeaderTitle.module.css"
|
import style from "@/app/[lang]/board/[board]/(page)/(header)/BoardHeaderTitle.module.css"
|
||||||
import {useBoardMetadataEditor} from "@/app/[lang]/board/[board]/(page)/useBoardMetadataEditor"
|
import {useBoardMetadataEditor} from "@/app/[lang]/board/[board]/(page)/useBoardMetadataEditor"
|
||||||
import cn from "classnames"
|
import cn from "classnames"
|
||||||
|
import {useMemo} from "react"
|
||||||
|
|
||||||
|
|
||||||
export function BoardHeaderTitle({className, editorHook}: {className?: string, editorHook: ReturnType<typeof useBoardMetadataEditor>}) {
|
export function BoardHeaderTitle({className, editorHook}: {className?: string, editorHook: ReturnType<typeof useBoardMetadataEditor>}) {
|
||||||
const {isReady, boardState: {title: titleFromState}} = useBoardConsumer()
|
const {isReady, boardState: {title: titleFromState}} = useBoardConsumer()
|
||||||
|
|
||||||
|
const pageTitle = useMemo(() => {
|
||||||
|
return titleFromState.length > 0 ? `${titleFromState} - Todocolors` : "Todocolors"
|
||||||
|
}, [titleFromState])
|
||||||
|
usePageTitleSetter(pageTitle)
|
||||||
|
|
||||||
if(!isReady) return null;
|
if(!isReady) return null;
|
||||||
|
|
||||||
let contents;
|
let contents;
|
||||||
|
|
|
@ -1,12 +1,4 @@
|
||||||
import {TaskEditor} from "@/app/[lang]/board/[board]/(page)/(edit)/TaskEditor"
|
|
||||||
import {BoardPage} from "@/app/[lang]/board/[board]/(page)/BoardPage"
|
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}}) {
|
export default function page({params: {lang}}: {params: {lang: string}}) {
|
||||||
|
|
Loading…
Reference in a new issue