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:
@@ -16,9 +16,10 @@ export type Node<T> = {
|
||||
export type Embeds =
|
||||
| {
|
||||
__typename: Exclude<ContentBlockType, "ImageContainer">
|
||||
system?: { uid: string } | undefined | null
|
||||
url?: string | undefined | null
|
||||
title?: string | undefined | null
|
||||
system?: { uid: string } | null
|
||||
url?: string | null
|
||||
permanent_url?: string | null
|
||||
title?: string | null
|
||||
}
|
||||
| {
|
||||
__typename: "ImageContainer"
|
||||
|
||||
@@ -404,13 +404,29 @@ export const renderOptions: RenderOptions = {
|
||||
)
|
||||
}
|
||||
}
|
||||
} else if (node.attrs["display-type"] === "link" && node.attrs.href) {
|
||||
} else if (node.attrs["display-type"] === "link") {
|
||||
const asset = embeds?.[node?.attrs?.["asset-uid"] as string]
|
||||
|
||||
// Decision note 2026-01-07:
|
||||
// Content team sometimes updates assets without updating the RTE reference.
|
||||
// The `permanent_url` should be used on the asset in Contentstack.
|
||||
// If this is not provided, we should not render the link.
|
||||
const rawUrl =
|
||||
asset?.node && "permanent_url" in asset.node
|
||||
? asset.node.permanent_url
|
||||
: null
|
||||
if (!rawUrl) {
|
||||
return null
|
||||
}
|
||||
|
||||
const { className, ...props } = extractPossibleAttributes(node.attrs)
|
||||
|
||||
const cleanUrl = rawUrl.split("?")[0]
|
||||
return (
|
||||
<TextLink
|
||||
key={node.uid}
|
||||
className={className}
|
||||
href={node.attrs.href as string}
|
||||
href={cleanUrl}
|
||||
target="_blank"
|
||||
isInline
|
||||
{...props}
|
||||
|
||||
Reference in New Issue
Block a user