feat: handling query string alias

This commit is contained in:
wonderlandpark 2021-05-29 02:22:38 +09:00
parent 420e358e10
commit 40273c58ff

View File

@ -39,6 +39,7 @@ const Search:NextPage<SearchProps> = ({ data, query }) => {
} }
export const getServerSideProps = async(ctx: Context) => { export const getServerSideProps = async(ctx: Context) => {
if(ctx.query.query && !ctx.query.q) ctx.query.q = ctx.query.query
if(!ctx.query?.q) { if(!ctx.query?.q) {
ctx.res.statusCode = 301 ctx.res.statusCode = 301
ctx.res.setHeader('Location', '/') ctx.res.setHeader('Location', '/')
@ -69,7 +70,8 @@ interface Context extends NextPageContext {
} }
interface URLQuery extends ParsedUrlQuery { interface URLQuery extends ParsedUrlQuery {
q: string q?: string
query?: string
page?: string page?: string
} }