From 545c59e65d9e5d44b090bcfcde4d804a277c221f Mon Sep 17 00:00:00 2001 From: Kohei Watanabe Date: Tue, 10 Mar 2020 17:26:17 +0900 Subject: [PATCH] use getStaticPaths/getStaticProps --- pages/query/[path].mdx | 9 --------- pages/query/[path].tsx | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 9 deletions(-) delete mode 100644 pages/query/[path].mdx create mode 100644 pages/query/[path].tsx diff --git a/pages/query/[path].mdx b/pages/query/[path].mdx deleted file mode 100644 index b75807c..0000000 --- a/pages/query/[path].mdx +++ /dev/null @@ -1,9 +0,0 @@ -import { useRouter } from "next/router"; -export const Query = () => { - const { query } = useRouter(); - return
{JSON.stringify(query, null, "  ")}
; -}; - -# Query - - diff --git a/pages/query/[path].tsx b/pages/query/[path].tsx new file mode 100644 index 0000000..2ed6f8b --- /dev/null +++ b/pages/query/[path].tsx @@ -0,0 +1,14 @@ +import { useRouter } from "next/router"; + +export function getStaticPaths() { + return { paths: [{ params: { path: "test" } }], fallback: true }; +} + +export function getStaticProps({ params }: { params: unknown }) { + return { props: params }; +} + +export default function({ path }: { path: string }) { + const { query } = useRouter(); + return
{JSON.stringify({ path, ...query }, null, "  ")}
; +}