diff --git a/packages/template-retail-react-app/app/page-designer/assets/image-with-text/index.jsx b/packages/template-retail-react-app/app/page-designer/assets/image-with-text/index.jsx index 73e7aa7cd8..62d79ef686 100644 --- a/packages/template-retail-react-app/app/page-designer/assets/image-with-text/index.jsx +++ b/packages/template-retail-react-app/app/page-designer/assets/image-with-text/index.jsx @@ -6,8 +6,9 @@ */ import React from 'react' import PropTypes from 'prop-types' -import {Box, Image, Text} from '@chakra-ui/react' +import {Box, Image, Link as ChakraLink, Text} from '@chakra-ui/react' import Link from '../../../components/link' +import {isAbsoluteURL} from '../../utils' /** * Image with text component @@ -22,6 +23,9 @@ import Link from '../../../components/link' */ export const ImageWithText = ({ITCLink, ITCText, image, heading, alt}) => { const hasCaption = ITCText || heading + const isAbsolute = isAbsoluteURL(ITCLink) + const LinkWrapper = isAbsolute ? ChakraLink : Link + const linkProps = isAbsolute ? {href: ITCLink} : {to: ITCLink} return ( @@ -35,7 +39,7 @@ export const ImageWithText = ({ITCLink, ITCText, image, heading, alt}) => { - + { title={alt} filter={'brightness(40%)'} /> - + {hasCaption && ( diff --git a/packages/template-retail-react-app/app/page-designer/utils.js b/packages/template-retail-react-app/app/page-designer/utils.js new file mode 100644 index 0000000000..27a91d9486 --- /dev/null +++ b/packages/template-retail-react-app/app/page-designer/utils.js @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2023, Salesforce, Inc. + * All rights reserved. + * SPDX-License-Identifier: BSD-3-Clause + * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause + */ + +/** + * Determines whether the specified URL is absolute + * + * @param {string} url The URL to test + * @returns {boolean} True if the specified URL is absolute, otherwise false + */ +export const isAbsoluteURL = (url) => /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url)