- add usePageTitle hook that writes '<title> | Liqa' to document.title - list pages use section name; detail pages use entity name once loaded - create/edit pages use static action title, edit includes entity name
18 lines
460 B
TypeScript
18 lines
460 B
TypeScript
import { useEffect } from 'react';
|
|
|
|
const APP_NAME = 'Liqa';
|
|
|
|
/**
|
|
* Sets document.title to "<title> | Liqa" for the current page.
|
|
* Pass undefined or empty string to fall back to just "Liqa".
|
|
*/
|
|
export function usePageTitle(title: string | null | undefined): void {
|
|
useEffect(() => {
|
|
const prev = document.title;
|
|
document.title = title ? `${title} | ${APP_NAME}` : APP_NAME;
|
|
return () => {
|
|
document.title = prev;
|
|
};
|
|
}, [title]);
|
|
}
|