Files
widget_templates/templates/widget-template/index.js
2025-07-15 13:03:23 +02:00

52 lines
1.1 KiB
JavaScript

// ##RUNTIME_IMPORT##
import { bootstrap, createHttpClient } from "@telia-ace/widget-core-flamingo";
// ##PLUGIN_IMPORTS##
const client = createHttpClient("https://widgets.ace.teliacompany.net/v1");
const getDetails = async () => {
const currentScript = new URL(import.meta.url);
const parts = currentScript.pathname.replace('/v1/install/', '').split('/');
const organization = parts[0];
const distribution = parts[1];
const resp = await fetch(`https://widgets.ace.teliacompany.net/v1/widget/dist/${organization}/${distribution}`);
const json = await resp.json();
return json.id;
};
(async () => {
getDetails();
let widgetId = "";
try {
widgetId = await getDetails();
} catch {
console.log("Widget not found");
return;
}
bootstrap(
{
httpClient: client,
apps: [
{
renderStrategy: "trigger",
autoActivate: true,
// widgetId: "__#_#WIDGET_ID__#__#",
widgetId: widgetId,
triggerIcon: "question",
},
],
},
(siteConfig) => {
siteConfig.applications.forEach((config) => {
// ##PLUGINS##
});
},
);
})();