From 439f10dad748a5d9b88c31633d4282ecd7dd6bcb Mon Sep 17 00:00:00 2001 From: Gokul TP <tp.gokul@gmail.com> Date: Wed, 8 Jun 2022 22:19:19 +0100 Subject: [PATCH 1/2] added users page --- next.config.js | 8 ++++++++ src/pages/users/[handle].tsx | 10 ++++++++++ 2 files changed, 18 insertions(+) create mode 100644 src/pages/users/[handle].tsx diff --git a/next.config.js b/next.config.js index 0b0be79..1f95e75 100644 --- a/next.config.js +++ b/next.config.js @@ -8,6 +8,14 @@ const nextConfig = { // return config; // }, + async rewrites() { + return [ + { + source: '/:handle(@[a-zA-Z0-9]+)/:id*', + destination: "/users/:handle/:id*", + } + ] + } } module.exports = nextConfig diff --git a/src/pages/users/[handle].tsx b/src/pages/users/[handle].tsx new file mode 100644 index 0000000..ca3cc02 --- /dev/null +++ b/src/pages/users/[handle].tsx @@ -0,0 +1,10 @@ +import { useRouter } from 'next/router' + +const User = () => { + const router = useRouter() + const { handle } = router.query + + return <h1>Welcome {handle}</h1> +} + +export default User \ No newline at end of file -- GitLab From d7a5e3bfd26f7ab9f9e3e9685d8e9bd07f6c41be Mon Sep 17 00:00:00 2001 From: Roshan Jossy <roshan.jossy@jina.ai> Date: Wed, 8 Jun 2022 23:29:31 +0200 Subject: [PATCH 2/2] fix handle for user page --- next.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/next.config.js b/next.config.js index 1f95e75..0c494e3 100644 --- a/next.config.js +++ b/next.config.js @@ -11,7 +11,7 @@ const nextConfig = { async rewrites() { return [ { - source: '/:handle(@[a-zA-Z0-9]+)/:id*', + source: '/@:handle([a-zA-Z0-9]+)/:id*', destination: "/users/:handle/:id*", } ] -- GitLab