Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | 89x 189x 189x 189x 34x | import {
SLUG_MAX_PREFIX_LENGTH_DESKTOP,
SLUG_MAX_PREFIX_LENGTH_MOBILE,
} from "@constants/constants";
import { useCustomTheme } from "@theme/hooks/useCustomTheme";
const useSlugPrefixFormatter = (prefix: string) => {
const { isMobileView } = useCustomTheme();
const maxLength = isMobileView
? SLUG_MAX_PREFIX_LENGTH_MOBILE
: SLUG_MAX_PREFIX_LENGTH_DESKTOP;
if (prefix?.length <= maxLength) return prefix;
return `${prefix?.slice(0, maxLength)}...`;
};
export default useSlugPrefixFormatter;
|