Skip to content

Commit

Permalink
support when empty link has text
Browse files Browse the repository at this point in the history
  • Loading branch information
xrutayisire committed Sep 7, 2024
1 parent d73bfef commit 3fd7cc4
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/react-server/PrismicLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ export const PrismicLink = React.forwardRef(function PrismicLink<
)}`,
);
} else if (
Object.keys(field).length > 1 &&
("text" in field
? Object.keys(field).length > 2
: Object.keys(field).length > 1) &&
!("url" in field || "uid" in field || "id" in field)
) {
console.warn(
Expand Down Expand Up @@ -173,7 +175,6 @@ export const PrismicLink = React.forwardRef(function PrismicLink<
}

const href = ("href" in restProps ? restProps.href : computedHref) || "";
const text = isFilled.link(field) ? field.text : undefined;

const InternalComponent = (internalComponent ||
defaultComponent) as React.ComponentType<LinkProps>;
Expand All @@ -184,7 +185,7 @@ export const PrismicLink = React.forwardRef(function PrismicLink<

return (
<Component ref={ref} {...attrs} {...restProps} href={href} rel={rel}>
{"children" in props ? children : text}
{"children" in props ? children : field?.text}
</Component>
);
}) as <
Expand Down

0 comments on commit 3fd7cc4

Please sign in to comment.