Merged in feat/SW-2111 (pull request #1761)
feat(SW-2111): add initial scandic-redirect * feat(SW-2111): add initial scandic-redirect * feat(SW-2112): add scandic-redirect call to middleware * chore: add redirect jsons per lang * fix: handle incorrect contentTypes * fix: handle lang * refactor: add json streaming * refactor: wrap redirect call in cacheOrGet * refactor: review Approved-by: Michael Zetterberg
This commit is contained in:
@@ -30,10 +30,18 @@ function getBreadcrumbsVariantsByContentType(
|
||||
}
|
||||
}
|
||||
|
||||
// We need to return null for both ignored content types and non-existent content types
|
||||
// In order to no having to maintain an explicit array of all content types besides the PageContentTypeEnum we convert it here.
|
||||
const allowedContentTypes = Object.keys(PageContentTypeEnum)
|
||||
.map((key) => {
|
||||
return PageContentTypeEnum[key as keyof typeof PageContentTypeEnum]
|
||||
})
|
||||
.filter((c) => !IGNORED_CONTENT_TYPES.includes(c))
|
||||
|
||||
export default function PageBreadcrumbs({
|
||||
params,
|
||||
}: PageArgs<LangParams & ContentTypeParams>) {
|
||||
if (IGNORED_CONTENT_TYPES.includes(params.contentType)) {
|
||||
if (!allowedContentTypes.includes(params.contentType)) {
|
||||
return null
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { notFound } from "next/navigation"
|
||||
|
||||
import styles from "./layout.module.css"
|
||||
|
||||
import type {
|
||||
@@ -6,17 +8,24 @@ import type {
|
||||
LayoutArgs,
|
||||
UIDParams,
|
||||
} from "@/types/params"
|
||||
import { PageContentTypeEnum } from "@/types/requests/contentType"
|
||||
|
||||
export default function ContentTypeLayout({
|
||||
breadcrumbs,
|
||||
preview,
|
||||
children,
|
||||
params,
|
||||
}: React.PropsWithChildren<
|
||||
LayoutArgs<LangParams & ContentTypeParams & UIDParams> & {
|
||||
breadcrumbs: React.ReactNode
|
||||
preview: React.ReactNode
|
||||
}
|
||||
>) {
|
||||
// Would like a better way to check if the contentType is valid.
|
||||
// Perhaps a case for using an `{} as const` object for PageContentTypes instead?
|
||||
if (!Object.values(PageContentTypeEnum).includes(params.contentType)) {
|
||||
notFound()
|
||||
}
|
||||
return (
|
||||
<div className={styles.container}>
|
||||
<section className={styles.layout}>
|
||||
|
||||
Reference in New Issue
Block a user