Set dynamic document titles per page
This commit is contained in:
@@ -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]);
|
||||
}
|
||||
Reference in New Issue
Block a user