UNPKG

@shopify/hydrogen-react

Version:

React components, hooks, and utilities for creating custom Shopify storefronts

56 lines (55 loc) 1.39 kB
import { jsx } from "react/jsx-runtime"; import { createElement } from "react"; const RichTextComponents = { root: Root, heading: Heading, paragraph: Paragraph, text: Text, link: RichTextLink, list: List, "list-item": ListItem }; function Root({ node }) { return /* @__PURE__ */ jsx("div", { children: node.children }); } function Heading({ node }) { return createElement(`h${node.level ?? "1"}`, null, node.children); } function Paragraph({ node }) { return /* @__PURE__ */ jsx("p", { children: node.children }); } function Text({ node }) { if (node.bold && node.italic) return /* @__PURE__ */ jsx("em", { children: /* @__PURE__ */ jsx("strong", { children: node.value }) }); if (node.bold) return /* @__PURE__ */ jsx("strong", { children: node.value }); if (node.italic) return /* @__PURE__ */ jsx("em", { children: node.value }); return node.value; } function RichTextLink({ node }) { return /* @__PURE__ */ jsx("a", { href: node.url, title: node.title, target: node.target, children: node.children }); } function List({ node }) { const List2 = node.listType === "unordered" ? "ul" : "ol"; return /* @__PURE__ */ jsx(List2, { children: node.children }); } function ListItem({ node }) { return /* @__PURE__ */ jsx("li", { children: node.children }); } export { RichTextComponents }; //# sourceMappingURL=RichText.components.mjs.map