Set dynamic document titles per page

This commit is contained in:
Steven RYDELL
2026-07-29 09:43:30 +02:00
parent 5152b07a9a
commit 544ee36a1e
7 changed files with 50 additions and 2 deletions
+17
View File
@@ -0,0 +1,17 @@
/*
* SPDX-FileCopyrightText: 2020 Stalwart Labs LLC <hello@stalw.art>
*
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL
*/
import { useEffect } from 'react';
const APP_NAME = 'Stalwart WebUI';
// Keeps the tab title in sync with the current page instead of the static
// index.html title; falls back to the bare app name when no page title is given.
export function useDocumentTitle(title?: string | null) {
useEffect(() => {
document.title = title ? `${title} · ${APP_NAME}` : APP_NAME;
}, [title]);
}