@se-studio/contentful-rest-api 1.0.24 → 1.0.26
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.js +43 -39
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -945,6 +945,19 @@ function collectIconsFromContent(contents) {
|
|
|
945
945
|
}
|
|
946
946
|
return icons;
|
|
947
947
|
}
|
|
948
|
+
function deduplicateIcons(...iconArrays) {
|
|
949
|
+
const seenIds = /* @__PURE__ */ new Set();
|
|
950
|
+
const icons = [];
|
|
951
|
+
for (const arr of iconArrays) {
|
|
952
|
+
for (const icon of arr) {
|
|
953
|
+
if (!seenIds.has(icon.id)) {
|
|
954
|
+
seenIds.add(icon.id);
|
|
955
|
+
icons.push(icon);
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
return icons.length > 0 ? icons : void 0;
|
|
960
|
+
}
|
|
948
961
|
async function processIconsForSprite(icons) {
|
|
949
962
|
if (icons.length === 0) {
|
|
950
963
|
return [];
|
|
@@ -1648,18 +1661,11 @@ function baseArticleConverter(context, entry) {
|
|
|
1648
1661
|
]);
|
|
1649
1662
|
const finalMenu = template?.menu;
|
|
1650
1663
|
const finalFooter = template?.footer;
|
|
1651
|
-
const
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
const icons = allIcons.filter((icon) => {
|
|
1657
|
-
if (seenIconIds.has(icon.id)) {
|
|
1658
|
-
return false;
|
|
1659
|
-
}
|
|
1660
|
-
seenIconIds.add(icon.id);
|
|
1661
|
-
return true;
|
|
1662
|
-
});
|
|
1664
|
+
const icons = deduplicateIcons(
|
|
1665
|
+
collectIconsFromContent(contents),
|
|
1666
|
+
collectIconsFromNavigation(finalMenu),
|
|
1667
|
+
collectIconsFromNavigation(finalFooter)
|
|
1668
|
+
);
|
|
1663
1669
|
const article = {
|
|
1664
1670
|
type: "Article",
|
|
1665
1671
|
id,
|
|
@@ -1670,7 +1676,7 @@ function baseArticleConverter(context, entry) {
|
|
|
1670
1676
|
articleType: articleTypeLink,
|
|
1671
1677
|
tags: tags?.map((tag) => resolveLink(context, id, tag)),
|
|
1672
1678
|
contents,
|
|
1673
|
-
icons
|
|
1679
|
+
icons,
|
|
1674
1680
|
...simpleFields,
|
|
1675
1681
|
// Note: summary field exists in Contentful but is not part of IArticle interface
|
|
1676
1682
|
// Keeping it in simpleFields for potential future use
|
|
@@ -1768,18 +1774,11 @@ function baseArticleTypeConverter(context, entry) {
|
|
|
1768
1774
|
const contents = addPositionMetadata([...topContent, ...preContent, ...postContent]);
|
|
1769
1775
|
const finalMenu = menu;
|
|
1770
1776
|
const finalFooter = footer;
|
|
1771
|
-
const
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
const icons = allIcons.filter((icon) => {
|
|
1777
|
-
if (seenIconIds.has(icon.id)) {
|
|
1778
|
-
return false;
|
|
1779
|
-
}
|
|
1780
|
-
seenIconIds.add(icon.id);
|
|
1781
|
-
return true;
|
|
1782
|
-
});
|
|
1777
|
+
const icons = deduplicateIcons(
|
|
1778
|
+
collectIconsFromContent(contents),
|
|
1779
|
+
collectIconsFromNavigation(finalMenu),
|
|
1780
|
+
collectIconsFromNavigation(finalFooter)
|
|
1781
|
+
);
|
|
1783
1782
|
const articleType = {
|
|
1784
1783
|
type: "Article type",
|
|
1785
1784
|
id,
|
|
@@ -1788,7 +1787,7 @@ function baseArticleTypeConverter(context, entry) {
|
|
|
1788
1787
|
description: makeContentfulDescription(indexPageDescription, sys.id),
|
|
1789
1788
|
featuredImage: lookupAsset(context, featuredImage),
|
|
1790
1789
|
contents,
|
|
1791
|
-
icons
|
|
1790
|
+
icons,
|
|
1792
1791
|
structuredData,
|
|
1793
1792
|
menu: finalMenu,
|
|
1794
1793
|
footer: finalFooter,
|
|
@@ -1925,6 +1924,11 @@ function baseCustomTypeConverter(context, entry) {
|
|
|
1925
1924
|
const preContent = template?.preContent ?? [];
|
|
1926
1925
|
const postContent = template?.postContent ?? [];
|
|
1927
1926
|
const contents = addPositionMetadata([...topContent, ...preContent, ...postContent]);
|
|
1927
|
+
const icons = deduplicateIcons(
|
|
1928
|
+
collectIconsFromContent(contents),
|
|
1929
|
+
collectIconsFromNavigation(menu),
|
|
1930
|
+
collectIconsFromNavigation(footer)
|
|
1931
|
+
);
|
|
1928
1932
|
const customType = {
|
|
1929
1933
|
type: "Custom type",
|
|
1930
1934
|
id,
|
|
@@ -1936,6 +1940,7 @@ function baseCustomTypeConverter(context, entry) {
|
|
|
1936
1940
|
description: makeContentfulDescription(indexPageDescription, sys.id),
|
|
1937
1941
|
featuredImage: lookupAsset(context, featuredImage),
|
|
1938
1942
|
contents,
|
|
1943
|
+
icons,
|
|
1939
1944
|
structuredData,
|
|
1940
1945
|
menu,
|
|
1941
1946
|
footer,
|
|
@@ -2092,18 +2097,11 @@ function basePageConverter(context, entry) {
|
|
|
2092
2097
|
]);
|
|
2093
2098
|
const finalMenu = pageMenuNav ?? template?.menu;
|
|
2094
2099
|
const finalFooter = pageFooterNav ?? template?.footer;
|
|
2095
|
-
const
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
const icons = allIcons.filter((icon) => {
|
|
2101
|
-
if (seenIconIds.has(icon.id)) {
|
|
2102
|
-
return false;
|
|
2103
|
-
}
|
|
2104
|
-
seenIconIds.add(icon.id);
|
|
2105
|
-
return true;
|
|
2106
|
-
});
|
|
2100
|
+
const icons = deduplicateIcons(
|
|
2101
|
+
collectIconsFromContent(contents),
|
|
2102
|
+
collectIconsFromNavigation(finalMenu),
|
|
2103
|
+
collectIconsFromNavigation(finalFooter)
|
|
2104
|
+
);
|
|
2107
2105
|
const page = {
|
|
2108
2106
|
type: "Page",
|
|
2109
2107
|
id,
|
|
@@ -2114,7 +2112,7 @@ function basePageConverter(context, entry) {
|
|
|
2114
2112
|
featuredImage: lookupAsset(context, featuredImage),
|
|
2115
2113
|
tags: tags?.map((tag) => resolveLink(context, id, tag)),
|
|
2116
2114
|
contents,
|
|
2117
|
-
icons
|
|
2115
|
+
icons,
|
|
2118
2116
|
...simpleFields,
|
|
2119
2117
|
menu: finalMenu,
|
|
2120
2118
|
footer: finalFooter
|
|
@@ -2244,6 +2242,11 @@ function baseTagConverter(context, entry) {
|
|
|
2244
2242
|
const preContent = template?.preContent ?? [];
|
|
2245
2243
|
const postContent = template?.postContent ?? [];
|
|
2246
2244
|
const contents = addPositionMetadata([...topContent, ...preContent, ...postContent]);
|
|
2245
|
+
const icons = deduplicateIcons(
|
|
2246
|
+
collectIconsFromContent(contents),
|
|
2247
|
+
collectIconsFromNavigation(menu),
|
|
2248
|
+
collectIconsFromNavigation(footer)
|
|
2249
|
+
);
|
|
2247
2250
|
const tagTypeEntry = tagType ? context.includes.get(tagType.sys.id) : null;
|
|
2248
2251
|
const tagTypeName = tagTypeEntry?.entry?.fields?.name;
|
|
2249
2252
|
const tag = {
|
|
@@ -2255,6 +2258,7 @@ function baseTagConverter(context, entry) {
|
|
|
2255
2258
|
featuredImage: lookupAsset(context, featuredImage),
|
|
2256
2259
|
tagType: tagTypeName ?? null,
|
|
2257
2260
|
contents,
|
|
2261
|
+
icons,
|
|
2258
2262
|
...rest,
|
|
2259
2263
|
menu,
|
|
2260
2264
|
footer
|