UNPKG

@prismicio/next

Version:

Helpers to integrate Prismic into Next.js apps

28 lines (27 loc) 1.04 kB
import { resolveDefaultExport } from "./lib/resolveDefaultExport.js"; import { asLinkAttrs } from "@prismicio/client"; import { forwardRef } from "react"; import { jsx } from "react/jsx-runtime"; import Link from "next/link.js"; //#region src/PrismicNextLink.tsx const PrismicNextLink = forwardRef(function PrismicNextLink(props, ref) { const { field, document, linkResolver, children, ...restProps } = props; const { href: computedHref, rel: computedRel, ...attrs } = asLinkAttrs(field ?? document, { linkResolver, rel: typeof restProps.rel === "function" ? restProps.rel : void 0 }); const href = ("href" in restProps ? restProps.href : computedHref) || ""; let rel = computedRel; if ("rel" in restProps && typeof restProps.rel !== "function") rel = restProps.rel; return /* @__PURE__ */ jsx(resolveDefaultExport(Link), { ref, ...attrs, ...restProps, href, rel, children: "children" in props ? children : field?.text }); }); //#endregion export { PrismicNextLink }; //# sourceMappingURL=PrismicNextLink.js.map