Files
web/server/routers/contentstack/destinationCountryPage/utils.ts
Erik Tiekstra a88a033e30 Merged in feat/SW-1450-destination-page-cs-components (pull request #1204)
feat(SW-1450): added components in destination pages from cs

* feat(SW-1450): added components in destination pages from cs

* feat(SW-1450): added correct refs and removed classNames


Approved-by: Fredrik Thorsson
2025-01-24 12:06:43 +00:00

33 lines
1.0 KiB
TypeScript

import { generateTag, generateTagsFromSystem } from "@/utils/generateTag"
import type { System } from "@/types/requests/system"
import type { GetDestinationCountryPageRefsSchema } from "@/types/trpc/routers/contentstack/destinationCountryPage"
import type { Lang } from "@/constants/languages"
export function generatePageTags(
validatedData: GetDestinationCountryPageRefsSchema,
lang: Lang
): string[] {
const connections = getConnections(validatedData)
return [
generateTagsFromSystem(lang, connections),
generateTag(lang, validatedData.destination_country_page.system.uid),
].flat()
}
export function getConnections({
destination_country_page,
}: GetDestinationCountryPageRefsSchema) {
const connections: System["system"][] = [destination_country_page.system]
if (destination_country_page.sidepeek_content) {
destination_country_page.sidepeek_content.content.embedded_itemsConnection.edges.forEach(
({ node }) => {
connections.push(node.system)
}
)
}
return connections
}