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 }