import { useEffect } from 'react'; const APP_NAME = 'Dorfteich'; /** * Route-specific document title (issue #163, WCAG 2.4.2): joins the given * parts with the app name ("Page — Pond — Dorfteich"). Empty/undefined * parts are skipped, so callers can pass still-loading data directly. * Falls back to the bare app name on unmount. */ export function useDocumentTitle(...parts: (string | null | undefined)[]): void { const joined = [...parts.filter(Boolean), APP_NAME].join(' — '); useEffect(() => { document.title = joined; }, [joined]); useEffect( () => () => { document.title = APP_NAME; }, [], ); }