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
38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
import { generateTag, generateTagsFromSystem } from "@/utils/generateTag"
|
|
|
|
import type { System } from "@/types/requests/system"
|
|
import type { GetDestinationCityPageRefsSchema } from "@/types/trpc/routers/contentstack/destinationCityPage"
|
|
import type { Lang } from "@/constants/languages"
|
|
|
|
export function generatePageTags(
|
|
validatedData: GetDestinationCityPageRefsSchema,
|
|
lang: Lang
|
|
): string[] {
|
|
const connections = getConnections(validatedData)
|
|
return [
|
|
generateTagsFromSystem(lang, connections),
|
|
generateTag(lang, validatedData.destination_city_page.system.uid),
|
|
].flat()
|
|
}
|
|
|
|
export function getConnections({
|
|
destination_city_page,
|
|
}: GetDestinationCityPageRefsSchema) {
|
|
const connections: System["system"][] = [destination_city_page.system]
|
|
|
|
connections.push(
|
|
destination_city_page.destination_settings.countryConnection.edges[0].node
|
|
.system
|
|
)
|
|
|
|
if (destination_city_page.sidepeek_content) {
|
|
destination_city_page.sidepeek_content.content.embedded_itemsConnection.edges.forEach(
|
|
({ node }) => {
|
|
connections.push(node.system)
|
|
}
|
|
)
|
|
}
|
|
|
|
return connections
|
|
}
|