arky-sdk 0.4.28 → 0.4.30
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/dist/index.cjs +20 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -612,6 +612,24 @@ var getBlockValue = (entry, blockKey) => {
|
|
|
612
612
|
const block = entry?.blocks?.find((f) => f.key === blockKey);
|
|
613
613
|
return block?.value ?? null;
|
|
614
614
|
};
|
|
615
|
+
var getBlockTextValue = (block, locale = "en") => {
|
|
616
|
+
if (!block || block.value === null || block.value === void 0) return "";
|
|
617
|
+
if (block.type === "LOCALIZED_TEXT" || block.type === "MARKDOWN") {
|
|
618
|
+
if (typeof block.value === "object" && block.value !== null) {
|
|
619
|
+
return block.value[locale] ?? block.value["en"] ?? "";
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
if (typeof block.value === "string") return block.value;
|
|
623
|
+
return String(block.value ?? "");
|
|
624
|
+
};
|
|
625
|
+
var getBlockValues = (entry, blockKey) => {
|
|
626
|
+
const block = entry?.blocks?.find((f) => f.key === blockKey);
|
|
627
|
+
if (!block) return [];
|
|
628
|
+
if (block.type === "BLOCK" && Array.isArray(block.value)) {
|
|
629
|
+
return block.value;
|
|
630
|
+
}
|
|
631
|
+
return [];
|
|
632
|
+
};
|
|
615
633
|
function unwrapBlock(block, locale) {
|
|
616
634
|
if (!block?.type || block.value === void 0) return block;
|
|
617
635
|
if (block.type === "BLOCK") {
|
|
@@ -1677,6 +1695,8 @@ async function createArkySDK(config) {
|
|
|
1677
1695
|
utils: {
|
|
1678
1696
|
getImageUrl: (imageBlock, isBlock = true) => getImageUrl(imageBlock, isBlock),
|
|
1679
1697
|
getBlockValue,
|
|
1698
|
+
getBlockTextValue,
|
|
1699
|
+
getBlockValues,
|
|
1680
1700
|
getBlockLabel,
|
|
1681
1701
|
getBlockObjectValues,
|
|
1682
1702
|
getBlockFromArray,
|