Added getExternalLink method to retrieve URL specified in CMS for the href link in a text-block

This commit is contained in:
Leah Schumann 2023-08-02 07:38:13 -04:00
parent 6855be6bdc
commit 0c719130ee
2 changed files with 13 additions and 1 deletions

View file

@ -14,7 +14,7 @@
<textLink
linkType="text"
:text="getRouterLinkDisplayTextFromCopy(copy)"
href="#!"
:href="getExternalLink(copy)"
@click-event="$emit('textLinkClicked', getRouterLinkRouteFromCopy(copy))"
:data-bs-target="'#' + getRouterLinkRouteFromCopy(copy)" />
</span>
@ -34,6 +34,7 @@ import {
splitCopyOnCMSPlaceHolder,
getRouterLinkRouteFromCopy,
getRouterLinkDisplayTextFromCopy,
getExternalLink,
} from "@/helpers/cms-content-helper";
import { applicationConfig } from "@/constants/application-config";
@ -53,6 +54,7 @@ export default {
splitCopyOnCMSPlaceHolder,
getRouterLinkRouteFromCopy,
getRouterLinkDisplayTextFromCopy,
getExternalLink,
},
computed: {
pageQueryString() {

View file

@ -310,6 +310,16 @@ export function getRouterLinkRouteFromCopy(copy) {
return copy.split(":")[1].split(",")[0];
}
export function getExternalLink(copy) {
let url = copy.split(":")[1].split(",")[0];
if (url.includes("https-")) {
const prefixAdded = url.replace("https-", "https://");
return prefixAdded;
}
return "#!";
}
/**
* Returns string3 of input following this pattern: {string1:string2,string3}
* @returns string