diff --git a/src/pages/components/[libId]/index.tsx b/src/pages/components/[libId]/index.tsx index 8ce46de18d89..f466930dd14e 100644 --- a/src/pages/components/[libId]/index.tsx +++ b/src/pages/components/[libId]/index.tsx @@ -7,8 +7,21 @@ import {libs} from '../../../content/components'; import {getI18nProps} from '../../../utils'; export const getServerSideProps: GetServerSideProps = async (ctx) => { + const libId = ctx.params?.libId as string; + + // Without this check any /components/ renders an empty shell with HTTP 200, + // so unlimited non-existent URLs are indexable as soft 404s. Mirrors the guard in + // src/pages/design/[sectionId]/index.tsx. + const lib = libs.find((item) => item.id === libId); + + if (!lib) { + return { + notFound: true, + }; + } + return { - props: {libId: ctx.params?.libId, ...(await getI18nProps(ctx))}, + props: {libId, ...(await getI18nProps(ctx))}, }; };