@se-studio/contentful-rest-api 1.0.21 → 1.0.22
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 +29 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1727,6 +1727,34 @@ function baseCustomTypeConverter(context, entry) {
|
|
|
1727
1727
|
};
|
|
1728
1728
|
return customType;
|
|
1729
1729
|
}
|
|
1730
|
+
function baseCustomTypeLinkConverter(context, entry) {
|
|
1731
|
+
const {
|
|
1732
|
+
sys: { id, contentType },
|
|
1733
|
+
fields
|
|
1734
|
+
} = entry;
|
|
1735
|
+
if (contentType.sys.id !== "customType") {
|
|
1736
|
+
throw new Error(`Invalid content type: expected "customType", got "${contentType.sys.id}"`);
|
|
1737
|
+
}
|
|
1738
|
+
return createInternalLink(
|
|
1739
|
+
id,
|
|
1740
|
+
{
|
|
1741
|
+
cmsLabel: fields.name,
|
|
1742
|
+
title: fields.name,
|
|
1743
|
+
featuredImage: fields.featuredImage,
|
|
1744
|
+
backgroundColour: fields.backgroundColour,
|
|
1745
|
+
textColour: fields.textColour,
|
|
1746
|
+
indexed: fields.indexed,
|
|
1747
|
+
hidden: fields.hidden,
|
|
1748
|
+
slug: fields.indexPageSlug
|
|
1749
|
+
},
|
|
1750
|
+
context,
|
|
1751
|
+
calculateCustomTypeHref(fields.indexPageSlug),
|
|
1752
|
+
"CustomType"
|
|
1753
|
+
);
|
|
1754
|
+
}
|
|
1755
|
+
function calculateCustomTypeHref(slug) {
|
|
1756
|
+
return `/${slug}/`;
|
|
1757
|
+
}
|
|
1730
1758
|
|
|
1731
1759
|
// src/converters/link.ts
|
|
1732
1760
|
function baseLinkConverter(context, entry) {
|
|
@@ -2016,6 +2044,7 @@ function createBaseConverterContext() {
|
|
|
2016
2044
|
linkResolver.set("person", basePersonLinkConverter);
|
|
2017
2045
|
linkResolver.set("pageVariant", basePageVariantLinkConverter);
|
|
2018
2046
|
linkResolver.set("link", baseLinkConverter);
|
|
2047
|
+
linkResolver.set("customType", baseCustomTypeLinkConverter);
|
|
2019
2048
|
const contentResolver = /* @__PURE__ */ new Map();
|
|
2020
2049
|
contentResolver.set("collection", baseCollectionConverter);
|
|
2021
2050
|
contentResolver.set("component", baseComponentConverter);
|