UNPKG

@kontent-ai/smart-link

Version:

Kontent.ai Smart Link SDK allowing to automatically inject [smart links](https://docs.kontent.ai/tutorials/develop-apps/build-strong-foundation/set-up-editing-from-preview#a-using-smart-links) to Kontent.ai according to manually specified [HTML data attri

42 lines 1.95 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.buildKontentItemLink = buildKontentItemLink; exports.buildKontentElementLink = buildKontentElementLink; /** * Builds a URL that opens the specified content item in the Kontent.ai web application editor. */ function buildKontentItemLink(params) { return `https://app.kontent.ai/goto/edit-item/project/${params.environmentId}/variant-codename/${params.languageCodename}/item/${params.itemId}`; } function buildElementLink(params) { return `${buildKontentItemLink({ environmentId: params.environmentId, languageCodename: params.languageCodename, itemId: params.itemId })}/element/${params.elementCodename}`; } function buildComponentElementLink(params) { return `${buildKontentItemLink({ environmentId: params.environmentId, languageCodename: params.languageCodename, itemId: params.itemId, })}/component/${params.contentComponentId}/element/${params.componentElementCodename}`; } /** * Builds a URL that opens a specific element within a content item in the Kontent.ai web application editor. * This function can handle both regular content elements and elements within content components. * If an element is within a component, 'contentComponentId' must be provided. */ function buildKontentElementLink(data) { return "contentComponentId" in data ? buildComponentElementLink({ environmentId: data.environmentId, languageCodename: data.languageCodename, itemId: data.itemId, contentComponentId: data.contentComponentId, componentElementCodename: data.componentElementCodename, }) : buildElementLink({ environmentId: data.environmentId, languageCodename: data.languageCodename, itemId: data.itemId, elementCodename: data.elementCodename, }); } //# sourceMappingURL=link.js.map