Merged in fix/hotel-subpage-unable-to-fetch (pull request #1381)
fix: was unable to fetch hotel subpage data, now uses the same function as when fetching a 'normal' hotel page * fix: was unable to fetch hotel subpage data, now uses the same function as when fetching a 'normal' hotel page Approved-by: Linus Flood
This commit is contained in:
committed by
Linus Flood
parent
7155165360
commit
00b94976b7
@@ -2,7 +2,6 @@ import { type NextMiddleware, NextResponse } from "next/server"
|
|||||||
|
|
||||||
import { notFound } from "@/server/errors/next"
|
import { notFound } from "@/server/errors/next"
|
||||||
|
|
||||||
import { fetchAndCacheEntry } from "@/services/cms/fetchAndCacheEntry"
|
|
||||||
import { getUidAndContentTypeByPath } from "@/services/cms/getUidAndContentTypeByPath"
|
import { getUidAndContentTypeByPath } from "@/services/cms/getUidAndContentTypeByPath"
|
||||||
import { findLang } from "@/utils/languages"
|
import { findLang } from "@/utils/languages"
|
||||||
import { removeTrailingSlash } from "@/utils/url"
|
import { removeTrailingSlash } from "@/utils/url"
|
||||||
@@ -37,17 +36,15 @@ export const middleware: NextMiddleware = async (request) => {
|
|||||||
if (incomingPathNameParts.length >= 2) {
|
if (incomingPathNameParts.length >= 2) {
|
||||||
const subpage = incomingPathNameParts.pop()
|
const subpage = incomingPathNameParts.pop()
|
||||||
if (subpage) {
|
if (subpage) {
|
||||||
const parentPageResult = await fetchAndCacheEntry(
|
let { contentType: parentContentType, uid: parentUid } =
|
||||||
incomingPathNameParts.join("/"),
|
await getUidAndContentTypeByPath(incomingPathNameParts.join("/"))
|
||||||
lang
|
|
||||||
)
|
|
||||||
|
|
||||||
if (parentPageResult.uid) {
|
if (parentUid) {
|
||||||
switch (parentPageResult.contentType) {
|
switch (parentContentType) {
|
||||||
case PageContentTypeEnum.hotelPage:
|
case PageContentTypeEnum.hotelPage:
|
||||||
// E.g. Dedicated pages for restaurant, parking etc.
|
// E.g. Dedicated pages for restaurant, parking etc.
|
||||||
contentType = parentPageResult.contentType
|
contentType = parentContentType
|
||||||
uid = parentPageResult.uid
|
uid = parentUid
|
||||||
searchParams.set("subpage", subpage)
|
searchParams.set("subpage", subpage)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user