stash/ui/v2.5/src/hooks/title.ts
DingDongSoLong4 5dbf1797e9
Details redesign tweaks and refactoring (#3995)
* Move loadStickyHeader to src/hooks
* intl stashIDs
* Scroll to top on component mount
* Add id to gallery cover image and tweak merge functions
* Add useTitleProps hook
* Also scroll to top on list pages
* Refactor loaders and tabs
* Use classnames
* Add DetailImage
2023-08-08 09:26:22 +10:00

26 lines
615 B
TypeScript

import { MessageDescriptor, useIntl } from "react-intl";
export const TITLE = "Stash";
export const TITLE_SEPARATOR = " | ";
export function useTitleProps(...messages: (string | MessageDescriptor)[]) {
const intl = useIntl();
const parts = messages.map((msg) => {
if (typeof msg === "object") {
return intl.formatMessage(msg);
} else {
return msg;
}
});
return makeTitleProps(...parts);
}
export function makeTitleProps(...parts: string[]) {
const title = [...parts, TITLE].join(TITLE_SEPARATOR);
return {
titleTemplate: `%s | ${title}`,
defaultTitle: title,
};
}