2022-08-11 20:29:46 +00:00
|
|
|
//@ts-check
|
|
|
|
|
2022-08-11 12:38:08 +00:00
|
|
|
/**
|
2022-08-11 20:29:46 +00:00
|
|
|
* Changes the document's title. Instead of passing the main title, you can also
|
|
|
|
* change the functions `title` member:
|
|
|
|
* ```js
|
|
|
|
* changeTitle.title = "My Site"
|
|
|
|
* changeTitle("Home") // produces "Home | My Site"
|
|
|
|
* ```
|
2022-08-11 12:38:08 +00:00
|
|
|
* @param {string} title
|
|
|
|
* @param {string} mainTitle
|
|
|
|
* @returns
|
|
|
|
*/
|
|
|
|
export const changeTitle = (title, mainTitle = changeTitle.title) =>
|
|
|
|
document && (document.title = `${title} | ${mainTitle}`);
|
|
|
|
|
|
|
|
changeTitle.title = (document && document.title) || "";
|
|
|
|
|
|
|
|
export default changeTitle;
|