Thanks a lot for this cool package!
It seems dyanmic routes do not work though, maybe this is a new next thing?
Steps to reproduce
Check out this repo
pnpm package:build
cd examples/app
pnpm dev
As a work around I created a utility function, but this is not ideal
import { format } from 'url';
import { type Route } from 'nextjs-routes';
export const routeToString = ({ query, pathname }: Route): Route => {
// Replace dynamic segments in the pathname with corresponding query values
let formattedPathname = pathname as string;
for (const key in query) {
const value = query[key];
// If the key is an array, join its elements with '/'
const replacedValue = Array.isArray(value) ? value.join('/') : value;
// Replace the dynamic segment with the query value
formattedPathname = formattedPathname.replace(`[${Array.isArray(value) ? '...' : ''}${key}]`, replacedValue!);
}
return format({ pathname: formattedPathname }) as unknown as Route;
};
Thanks a lot for this cool package! It seems dyanmic routes do not work though, maybe this is a new next thing?
Steps to reproduce
Check out this repo
As a work around I created a utility function, but this is not ideal