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
33 lines
1.0 KiB
TypeScript
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
|
|
}
|