18 lines
594 B
TypeScript
18 lines
594 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}?${new URLSearchParams(urlSearchParams)}`;
|
|
|
|
return path + route;
|
|
};
|
|
}
|
|
|
|
export type CreateUrl = ReturnType<typeof makeCreateUrl>;
|