tatethurston / nextjs-routes

Type safe routing for Next.js
MIT License
571 stars 23 forks source link

allow passing in query without pathname #20

Closed sachinraja closed 2 years ago

sachinraja commented 2 years ago

Next's <Link> allows us to pass in query without having to specify the pathname, assuming that we are changing query parameters on the same URL that the user is currently on. This PR updates the types to allow doing that with nextjs-routes.

codecov[bot] commented 2 years ago

Codecov Report

Merging #20 (8abab41) into main (e882157) will not change coverage. The diff coverage is n/a.

@@           Coverage Diff           @@
##             main      #20   +/-   ##
=======================================
  Coverage   98.24%   98.24%           
=======================================
  Files           1        1           
  Lines          57       57           
  Branches       13       13           
=======================================
  Hits           56       56           
  Misses          1        1           
Impacted Files Coverage Δ
src/utils.ts 98.24% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update e882157...8abab41. Read the comment docs.

tatethurston commented 2 years ago

Thanks @sachinraja! I wasn't aware of this capability.

Do the router methods (eg router.push) also support this behavior?

tatethurston commented 2 years ago

😆 Looks like we had the same thought

sachinraja commented 2 years ago

Haha I just (literally 5 seconds before) added it for router.push.

Edit: I'll also add it for router.replace. (done)

tatethurston commented 2 years ago

I'm going to look into writing some type tests so we don't regress and then I'll publish 0.0.14 tonight.

sachinraja commented 2 years ago

Thanks for being so responsive!