Skip to content

Commit c30b6cd

Browse files
authored
chore: custom endpoint for widget (#597)
1 parent a3fa8aa commit c30b6cd

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

config/widget/fullscreen/wrapper.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ export async function fullscreen(options) {
1212

1313
const shadow = hostElement.attachShadow({ mode: "open" });
1414

15-
const linkHref = "$[[ENDPOINT]]/widgets/fullscreen/index.css?v=$[[VER]]";
15+
const endpoint = options.endpoint || "$[[ENDPOINT]]";
16+
17+
const linkHref = endpoint + "/widgets/fullscreen/index.css?v=$[[VER]]";
1618
const linkElement = document.createElement("link");
1719
linkElement.rel = "stylesheet";
1820
linkElement.href = linkHref;
@@ -24,15 +26,15 @@ export async function fullscreen(options) {
2426
shadow.appendChild(wrapper);
2527

2628
const { fullscreen: originalFullscreen } = await import(
27-
"$[[ENDPOINT]]/widgets/fullscreen/index.js?v=$[[VER]]"
29+
endpoint + "/widgets/fullscreen/index.js?v=$[[VER]]"
2830
);
2931

3032
const finalOptions = {
3133
...options,
3234
shadow,
3335
container: wrapper,
3436
id: "$[[ID]]",
35-
server: "$[[ENDPOINT]]",
37+
server: endpoint,
3638
linkHref
3739
};
3840

config/widget/searchbox/wrapper.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { searchbox as originalSearchbox } from "$[[ENDPOINT]]/widgets/searchbox/index.js?v=$[[VER]]";
2-
31
export async function searchbox(options) {
42
if (!options || !options.container) {
53
console.error("Container is required in options.");
@@ -14,7 +12,9 @@ export async function searchbox(options) {
1412

1513
const shadow = hostElement.attachShadow({ mode: "open" });
1614

17-
const linkHref = "$[[ENDPOINT]]/widgets/searchbox/index.css?v=$[[VER]]";
15+
const endpoint = options.endpoint || "$[[ENDPOINT]]";
16+
const linkHref = endpoint + "/widgets/searchbox/index.css?v=$[[VER]]";
17+
1818
const linkElement = document.createElement("link");
1919
linkElement.rel = "stylesheet";
2020
linkElement.href = linkHref;
@@ -26,14 +26,14 @@ export async function searchbox(options) {
2626
shadow.appendChild(wrapper);
2727

2828
const { searchbox: originalSearchbox } = await import(
29-
"$[[ENDPOINT]]/widgets/searchbox/index.js?v=$[[VER]]"
29+
endpoint + "/widgets/searchbox/index.js?v=$[[VER]]"
3030
);
3131

3232
const finalOptions = {
3333
...options,
3434
container: wrapper,
3535
id: "$[[ID]]",
36-
server: "$[[ENDPOINT]]",
36+
server: endpoint,
3737
linkHref
3838
};
3939

0 commit comments

Comments
 (0)