@builder.io/sdk-solid 0.1.15 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -7,9 +7,16 @@ function Button(props) {
|
|
|
7
7
|
<Show
|
|
8
8
|
fallback={
|
|
9
9
|
<button
|
|
10
|
-
class={
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
class={
|
|
11
|
+
/**
|
|
12
|
+
* We have to explicitly provide `class` so that Mitosis knows to merge it with `css`.
|
|
13
|
+
*/
|
|
14
|
+
props.attributes.class +
|
|
15
|
+
" " +
|
|
16
|
+
css({
|
|
17
|
+
all: "unset",
|
|
18
|
+
})
|
|
19
|
+
}
|
|
13
20
|
{...props.attributes}
|
|
14
21
|
>
|
|
15
22
|
{props.text}
|
|
@@ -42,7 +42,11 @@ import { handleABTesting } from "./ab-testing.js";
|
|
|
42
42
|
import { generateContentUrl } from "./generate-content-url.js";
|
|
43
43
|
function getContent(options) {
|
|
44
44
|
return __async(this, null, function* () {
|
|
45
|
-
|
|
45
|
+
const allContent = yield getAllContent(__spreadProps(__spreadValues({}, options), { limit: 1 }));
|
|
46
|
+
if ("results" in allContent) {
|
|
47
|
+
return (allContent == null ? void 0 : allContent.results[0]) || null;
|
|
48
|
+
}
|
|
49
|
+
return null;
|
|
46
50
|
});
|
|
47
51
|
}
|
|
48
52
|
function getAllContent(options) {
|
|
@@ -50,11 +54,19 @@ function getAllContent(options) {
|
|
|
50
54
|
const url = generateContentUrl(options);
|
|
51
55
|
const res = yield fetch(url.href);
|
|
52
56
|
const content = yield res.json();
|
|
57
|
+
if ("status" in content && !("results" in content)) {
|
|
58
|
+
console.error("[Builder.io]: Error fetching data. ", content, options);
|
|
59
|
+
return content;
|
|
60
|
+
}
|
|
53
61
|
const canTrack = options.canTrack !== false;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
62
|
+
try {
|
|
63
|
+
if (canTrack && Array.isArray(content.results)) {
|
|
64
|
+
for (const item of content.results) {
|
|
65
|
+
yield handleABTesting({ item, canTrack });
|
|
66
|
+
}
|
|
57
67
|
}
|
|
68
|
+
} catch (e) {
|
|
69
|
+
console.error("[Builder.io]: Could not setup A/B testing. ", e);
|
|
58
70
|
}
|
|
59
71
|
return content;
|
|
60
72
|
});
|