2023-11-16 14:38:15 +03:00

18 lines
573 B
TypeScript

import type { PageProps } from '@/types/page';
export function getPageUrlParams({ params, searchParams }: PageProps) {
return { path: `/${params.slug}`, urlSearchParams: new URLSearchParams(searchParams) };
}
export type PageUrlParams = ReturnType<typeof getPageUrlParams>;
export function makeCreateUrl({ path, urlSearchParams }: ReturnType<typeof getPageUrlParams>) {
return function (route: string) {
if (urlSearchParams) return `${path}${route}?${urlSearchParams}`;
return path + route;
};
}
export type CreateUrl = ReturnType<typeof makeCreateUrl>;