Skip to content

Commit

Permalink
feat: support link text
Browse files Browse the repository at this point in the history
  • Loading branch information
xrutayisire committed Aug 28, 2024
1 parent df6fda8 commit bdc244e
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 193 deletions.
215 changes: 26 additions & 189 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
"negotiator": "^0.6.3"
},
"devDependencies": {
"@prismicio/client": "^7.2.0",
"@prismicio/mock": "^0.3.1",
"@prismicio/client": "7.9.0-alpha.2",
"@prismicio/mock": "0.3.8-alpha.0",
"@size-limit/preset-small-lib": "^9.0.0",
"@types/negotiator": "^0.6.3",
"@types/react-test-renderer": "^18.0.2",
Expand Down Expand Up @@ -99,5 +99,9 @@
},
"publishConfig": {
"access": "public"
},
"overrides": {
"@prismicio/client": "7.9.0-alpha.2",
"@prismicio/mock": "0.3.8-alpha.0"
}
}
13 changes: 11 additions & 2 deletions src/PrismicNextLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const PrismicNextLink = React.forwardRef<
HTMLAnchorElement,
PrismicNextLinkProps
>(function PrismicNextLink(
{ field, document, linkResolver, ...restProps },
{ field, document, linkResolver, children, ...restProps },
ref,
): JSX.Element | null {
const {
Expand All @@ -51,5 +51,14 @@ export const PrismicNextLink = React.forwardRef<
rel = restProps.rel;
}

return <Link ref={ref} {...attrs} {...restProps} href={href} rel={rel} />;
let text: string | undefined;
if (field && "text" in field) {
text = field.text;
}

return (
<Link ref={ref} {...attrs} {...restProps} href={href} rel={rel}>
{children || text}
</Link>
);
});
Loading

0 comments on commit bdc244e

Please sign in to comment.