feat(BOOK-609): Using embedded url for assets instead of href since that is not updated when the asset is updated)

* feat(BOOK-609): Updated refs handling for assets inside content pages

Approved-by: Linus Flood
This commit is contained in:
Erik Tiekstra
2026-01-13 10:40:36 +00:00
parent 6ae4c7c805
commit 8d34089637
19 changed files with 194 additions and 147 deletions

View File

@@ -76,8 +76,7 @@ export function generatePageTags(
validatedData: ContentPageRefs,
lang: Lang
): string[] {
const connections = getConnections(validatedData)
const assetConnections = getConnectionsFromAssets(validatedData)
const { connections, assetConnections } = getConnections(validatedData)
return [
generateTagsFromSystem(lang, connections),
generateTagsFromAssetSystem(assetConnections),
@@ -85,40 +84,15 @@ export function generatePageTags(
].flat()
}
export function getConnectionsFromAssets({ content_page }: ContentPageRefs) {
const connections: AssetSystem["system"][] = []
if (content_page.hero_video?.sourceConnection.edges[0]) {
connections.push(
content_page.hero_video.sourceConnection.edges[0].node.system
)
}
if (content_page.blocks) {
content_page.blocks.forEach((block) => {
switch (block.__typename) {
case ContentPageEnum.ContentStack.blocks.VideoCard:
if (block.video_card?.video.sourceConnection.edges[0]) {
connections.push(
block.video_card.video.sourceConnection.edges[0].node.system
)
}
break
case ContentPageEnum.ContentStack.blocks.Video:
if (block.video?.sourceConnection.edges[0]) {
connections.push(block.video.sourceConnection.edges[0].node.system)
}
break
default:
break
}
})
}
return connections
}
export function getConnections({ content_page }: ContentPageRefs) {
const connections: System["system"][] = [content_page.system]
const assetConnections: AssetSystem[] = []
if (content_page.hero_video?.sourceConnection.edges[0]) {
assetConnections.push(
content_page.hero_video.sourceConnection.edges[0].node
)
}
if (content_page.blocks) {
content_page.blocks.forEach((block) => {
@@ -130,10 +104,14 @@ export function getConnections({ content_page }: ContentPageRefs) {
}
break
case ContentPageEnum.ContentStack.blocks.Content:
{
if (block?.content?.length) {
connections.push(...block.content)
}
if (block?.content?.length) {
block.content.forEach((contentBlock) => {
if ("system" in contentBlock) {
assetConnections.push(contentBlock)
} else {
connections.push(contentBlock)
}
})
}
break
case ContentPageEnum.ContentStack.blocks.CardsGrid:
@@ -172,8 +150,16 @@ export function getConnections({ content_page }: ContentPageRefs) {
if (block.video_card) {
connections.push(block.video_card.system)
}
if (block.video_card?.video.sourceConnection.edges[0]) {
assetConnections.push(
block.video_card.video.sourceConnection.edges[0].node
)
}
break
case ContentPageEnum.ContentStack.blocks.Video:
if (block.video?.sourceConnection.edges[0]) {
assetConnections.push(block.video.sourceConnection.edges[0].node)
}
break
case ContentPageEnum.ContentStack.blocks.Jotform:
if (block.jotform) {
@@ -192,8 +178,14 @@ export function getConnections({ content_page }: ContentPageRefs) {
const typeName = block.__typename
switch (typeName) {
case ContentPageEnum.ContentStack.sidebar.Content:
if (block.content.length) {
connections.push(...block.content.filter((c) => !!c))
if (block.content?.length) {
block.content.forEach((contentBlock) => {
if ("system" in contentBlock) {
assetConnections.push(contentBlock)
} else {
connections.push(contentBlock)
}
})
}
break
case ContentPageEnum.ContentStack.sidebar.JoinLoyaltyContact:
@@ -222,5 +214,5 @@ export function getConnections({ content_page }: ContentPageRefs) {
}
})
}
return connections
return { connections, assetConnections }
}