mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
add test for context.params
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "my-app",
|
||||
"version": "0.1.0",
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
"build": "next build",
|
||||
"start": "next start"
|
||||
},
|
||||
"dependencies": {
|
||||
"next": "^10.0.0",
|
||||
"react": "17.0.1",
|
||||
"react-dom": "17.0.1"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import type { GetServerSidePropsContext, GetStaticProps, GetStaticPropsContext, InferGetServerSidePropsType, InferGetStaticPropsType, NextPage } from 'next'
|
||||
|
||||
type Props = InferGetServerSidePropsType<typeof getServerSideProps>
|
||||
|
||||
const Home: NextPage<Props> = ({ id, url }) => {
|
||||
return (
|
||||
<>
|
||||
<div dangerouslySetInnerHTML={{__html: url }} />
|
||||
<div dangerouslySetInnerHTML={{__html: id }} />
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
export function getServerSideProps(context: GetServerSidePropsContext<{ id: string, url: string }>) {
|
||||
return {
|
||||
props: {
|
||||
id: context.params?.id,
|
||||
url: decodeURIComponent(context.req.url || "")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export default Home
|
||||
Reference in New Issue
Block a user