mirror of
https://github.com/kou029w/_.git
synced 2025-02-07 09:38:46 +00:00
use getStaticPaths/getStaticProps
This commit is contained in:
parent
7c18ed2a3e
commit
545c59e65d
2 changed files with 14 additions and 9 deletions
|
@ -1,9 +0,0 @@
|
||||||
import { useRouter } from "next/router";
|
|
||||||
export const Query = () => {
|
|
||||||
const { query } = useRouter();
|
|
||||||
return <pre>{JSON.stringify(query, null, " ")}</pre>;
|
|
||||||
};
|
|
||||||
|
|
||||||
# Query
|
|
||||||
|
|
||||||
<Query />
|
|
14
pages/query/[path].tsx
Normal file
14
pages/query/[path].tsx
Normal file
|
@ -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 <pre>{JSON.stringify({ path, ...query }, null, " ")}</pre>;
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue