Big boy
Big boy

Reputation: 1761

How to limit value types in director-based routing in Qwik?

If you want to have a blog with pagination, this can be one routing example in Qwik:

- src
  - routes
    - blog
      - index.jsx
      - [pageNumber]
        - index.jsx

And it works for /blog and /blog/2 URLs.

The problem is that, it also works for /blog/john and /blog/j!o*hn too.

In other words, it's not limited to numbers only.

How can I limit route values to specific types only?

Upvotes: 0

Views: 50

Answers (1)

thecoder93
thecoder93

Reputation: 31

I believe which on query string you going to have always a string type. After that you should use useLocation().params.pageNumber and then check if is a number o string.

Upvotes: 1

Related Questions