Merge pull request #7

fix: TypeError: Cannot read property 'trim' of undefined at getStaticProps
This commit is contained in:
Dawid Wysokiński 2021-05-28 17:32:59 +02:00 committed by GitHub
commit ce5bd8dda5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -1,4 +1,5 @@
import { GetStaticPaths, GetStaticProps } from 'next';
import { isString, isNil } from 'lodash';
import { polishPlurals } from 'polish-plurals';
import {
createClient,
@ -73,7 +74,8 @@ export const getStaticProps: GetStaticProps<
},
};
if (!params) return { notFound: true, revalidate: REVALIDATE_ERROR };
if (!params || isNil(params.limit) || !isString(params.slug))
return { notFound: true, revalidate: REVALIDATE_ERROR };
const limit = parseInt(params.limit);
const slug = params.slug.trim();
if (