mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-12-01 20:36:21 -05:00
Adding useTitle to every function page.
This commit is contained in:
parent
1033b0c38f
commit
5bf648001b
12 changed files with 55 additions and 12 deletions
|
|
@ -11,6 +11,7 @@ export const VIDEOS_API = `${API_URI}/videos`;
|
|||
export const ARCHIVES_API = `${API_URI}/archive`;
|
||||
export const OTP_API = `${API_URI}/otp`;
|
||||
export const DEFAULT_LIMIT = 20;
|
||||
export const NAME = process.env && process.env.REACT_APP_NAME ? process.env.REACT_APP_NAME : null;
|
||||
|
||||
export function Paginator({activePage, onPageChange, totalPages, showFirstAndLast, size = 'mini'}) {
|
||||
const handlePageChange = (e, {activePage}) => {
|
||||
|
|
@ -777,18 +778,19 @@ export function HotspotStatusIcon() {
|
|||
export function useTitle(title) {
|
||||
const documentDefined = typeof document !== 'undefined';
|
||||
const originalTitle = React.useRef(documentDefined ? document.title : null);
|
||||
const name = NAME ? `${NAME} WROLPi` : `WROLPi`;
|
||||
|
||||
useEffect(() => {
|
||||
if (!documentDefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
const newTitle = `${title} - WROLPi`
|
||||
const newTitle = `${title} - ${name}`
|
||||
if (title && document.title !== newTitle) {
|
||||
document.title = newTitle;
|
||||
}
|
||||
return () => {
|
||||
document.title = originalTitle.current;
|
||||
}
|
||||
}, []);
|
||||
}, [title]);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue