Merged in feat/SW-1584-destination-content-blocks (pull request #1278)

Feat/SW-1584 destination content blocks

* feat(SW-1584): Added accordion and content blocks to destination city pages

* feat(SW-1584): Added accordion and content blocks to destination country pages


Approved-by: Matilda Landström
This commit is contained in:
Erik Tiekstra
2025-02-10 09:28:32 +00:00
parent 918887a63f
commit eb0b88f8ea
18 changed files with 546 additions and 33 deletions
@@ -14,14 +14,15 @@ import {
} from "./telemetry"
import { ApiCountry, type Country } from "@/types/enums/country"
import { DestinationCountryPageEnum } from "@/types/enums/destinationCountryPage"
import type { RequestOptionsWithOutBody } from "@/types/fetch"
import type { System } from "@/types/requests/system"
import type { GetDestinationCityListDataResponse } from "@/types/trpc/routers/contentstack/destinationCityPage"
import type { GetDestinationCountryPageRefsSchema } from "@/types/trpc/routers/contentstack/destinationCountryPage"
import type { DestinationCountryPageRefs } from "@/types/trpc/routers/contentstack/destinationCountryPage"
import type { Lang } from "@/constants/languages"
export function generatePageTags(
validatedData: GetDestinationCountryPageRefsSchema,
validatedData: DestinationCountryPageRefs,
lang: Lang
): string[] {
const connections = getConnections(validatedData)
@@ -33,9 +34,29 @@ export function generatePageTags(
export function getConnections({
destination_country_page,
}: GetDestinationCountryPageRefsSchema) {
}: DestinationCountryPageRefs) {
const connections: System["system"][] = [destination_country_page.system]
if (destination_country_page.blocks) {
destination_country_page.blocks.forEach((block) => {
switch (block.__typename) {
case DestinationCountryPageEnum.ContentStack.blocks.Accordion: {
if (block.accordion.length) {
connections.push(...block.accordion)
}
break
}
case DestinationCountryPageEnum.ContentStack.blocks.Content:
{
if (block.content.length) {
// TS has trouble infering the filtered types
// @ts-ignore
connections.push(...block.content)
}
}
break
}
})
}
if (destination_country_page.sidepeek_content) {
destination_country_page.sidepeek_content.content.embedded_itemsConnection.edges.forEach(
({ node }) => {