From 9e2f51eb5f108f346d9fac62f9689801453da8f1 Mon Sep 17 00:00:00 2001
From: yudejp
Date: Sun, 3 Oct 2021 13:12:11 +0900
Subject: [PATCH] Add UUID lookup function Now player's profile page works on
IGN query too
---
next.config.js | 4 +--
pages/minecraft/lookup/[ign].js | 57 +++++++++++++++++++++++++++++++++
2 files changed, 59 insertions(+), 2 deletions(-)
create mode 100644 pages/minecraft/lookup/[ign].js
diff --git a/next.config.js b/next.config.js
index c3e326e..66869c3 100644
--- a/next.config.js
+++ b/next.config.js
@@ -7,8 +7,8 @@ const rewrites = async () => {
destination: '/minecraft/players/:uuid'
},
{
- source: '/minecraft/players/:uuid',
- destination: '/404'
+ source: '/minecraft/players/:ign',
+ destination: '/minecraft/lookup/:ign'
}
]
}
diff --git a/pages/minecraft/lookup/[ign].js b/pages/minecraft/lookup/[ign].js
new file mode 100644
index 0000000..cb2a495
--- /dev/null
+++ b/pages/minecraft/lookup/[ign].js
@@ -0,0 +1,57 @@
+ // Base layout
+ import Layout from "../../components/Layout"
+
+ // React
+ import { useRouter } from 'next/router'
+
+ // Data fetching
+ import Players from '../../components/Minecraft/Players'
+ import useSwr from 'swr'
+ const fetcher = (url) => fetch(url).then((res) => res.json())
+
+ // Components
+ import WrongUUID from '../../components/Minecraft/WrongUUID'
+
+ export default function UUID() {
+ const router = useRouter()
+ const { ign } = router.query
+ const { data, error } = useSwr(
+ ign ? `https://api.ashcon.app/mojang/v2/user/${ign}` : null,
+ fetcher
+ )
+ if (error) {
+ return (
+ <>
+ エラーが発生しました。 読み込み中
リダイレクトしています...
+ ) + } + } + } + } + \ No newline at end of file