aboutsummaryrefslogtreecommitdiff
path: root/src/components/hooks/useSlug.ts
blob: f795dfeb35d40bd617e032dcbc7c0f95cbe0c233 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import { useConfig } from '@/components/hooks/useConfig';
import { LINKS_URL, PIXELS_URL } from '@/lib/constants';

export function useSlug(type: 'link' | 'pixel') {
  const { linksUrl, pixelsUrl } = useConfig();

  const hostUrl = type === 'link' ? linksUrl || LINKS_URL : pixelsUrl || PIXELS_URL;

  const getSlugUrl = (slug: string) => {
    return `${hostUrl}/${slug}`;
  };

  return { getSlugUrl, hostUrl };
}