mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-15 09:46:16 +01:00
Set custom page title
This commit is contained in:
@@ -1,17 +1,30 @@
|
|||||||
import React from "react";
|
import React, { FC, useEffect } from "react";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
title?: string;
|
title?: string;
|
||||||
|
customPageTitle?: string;
|
||||||
|
preventRefreshingPageTitle?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Title extends React.Component<Props> {
|
const Title: FC<Props> = ({ title, preventRefreshingPageTitle, customPageTitle }) => {
|
||||||
render() {
|
useEffect(() => {
|
||||||
const { title } = this.props;
|
if (!preventRefreshingPageTitle) {
|
||||||
|
if (customPageTitle) {
|
||||||
|
document.title = customPageTitle;
|
||||||
|
} else if (title) {
|
||||||
|
document.title = title;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if (title) {
|
if (title) {
|
||||||
return <h1 className="title">{title}</h1>;
|
return <h1 className="title">{title}</h1>;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
};
|
||||||
}
|
|
||||||
|
Title.defaultProps = {
|
||||||
|
preventRefreshingPageTitle: false
|
||||||
|
};
|
||||||
|
|
||||||
export default Title;
|
export default Title;
|
||||||
|
|||||||
Reference in New Issue
Block a user