@se-studio/contentful-rest-api 1.0.32 → 1.0.33
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.d.ts +1 -1
- package/dist/index.js +11 -16
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -406,7 +406,7 @@ type LinkResolverMap = Map<string, LinkResolverFunction>;
|
|
|
406
406
|
type UrlCalculators = {
|
|
407
407
|
page: (slug: string) => string;
|
|
408
408
|
pageVariant: (slug: string) => string;
|
|
409
|
-
article: (articleTypeSlug: string, slug: string) => string;
|
|
409
|
+
article: (articleTypeSlug: string, slug: string, primaryTagSlug?: string) => string;
|
|
410
410
|
articleType: (slug: string) => string;
|
|
411
411
|
tag: (slug: string) => string;
|
|
412
412
|
person: (slug: string) => string;
|
package/dist/index.js
CHANGED
|
@@ -1031,7 +1031,7 @@ function safeDate(date) {
|
|
|
1031
1031
|
|
|
1032
1032
|
// src/api/helpers.ts
|
|
1033
1033
|
var PAGE_LINK_FIELDS = "sys,fields.cmsLabel,fields.title,fields.slug,fields.featuredImage,fields.backgroundColour,fields.textColour,fields.indexed,fields.hidden,fields.tags";
|
|
1034
|
-
var ARTICLE_LINK_FIELDS = "sys,fields.cmsLabel,fields.title,fields.slug,fields.featuredImage,fields.backgroundColour,fields.textColour,fields.indexed,fields.hidden,fields.tags,fields.articleType,fields.date,fields.author";
|
|
1034
|
+
var ARTICLE_LINK_FIELDS = "sys,fields.cmsLabel,fields.title,fields.slug,fields.featuredImage,fields.backgroundColour,fields.textColour,fields.indexed,fields.hidden,fields.tags,fields.articleType,fields.date,fields.author,fields.externalLink";
|
|
1035
1035
|
var ARTICLE_TYPE_LINK_FIELDS = "sys,fields.name,fields.slug,fields.featuredImage,fields.backgroundColour,fields.textColour,fields.indexed,fields.hidden";
|
|
1036
1036
|
var TAG_LINK_FIELDS = "sys,fields.cmsLabel,fields.name,fields.slug,fields.featuredImage,fields.backgroundColour,fields.textColour,fields.indexed,fields.hidden";
|
|
1037
1037
|
var PERSON_LINK_FIELDS = "sys,fields.name,fields.slug,fields.media,fields.backgroundColour,fields.textColour,fields.indexed,fields.hidden";
|
|
@@ -1734,7 +1734,7 @@ function baseArticleConverter(context, entry) {
|
|
|
1734
1734
|
function calculateArticleTypeHref(slug) {
|
|
1735
1735
|
return `/${slug}/`;
|
|
1736
1736
|
}
|
|
1737
|
-
function calculateArticleHref(articleTypeSlug, slug) {
|
|
1737
|
+
function calculateArticleHref(articleTypeSlug, slug, _primaryTagSlug) {
|
|
1738
1738
|
return `${calculateArticleTypeHref(articleTypeSlug)}${slug}/`;
|
|
1739
1739
|
}
|
|
1740
1740
|
function baseArticleLinkConverter(context, entry) {
|
|
@@ -1747,26 +1747,21 @@ function baseArticleLinkConverter(context, entry) {
|
|
|
1747
1747
|
tags: fieldsTags,
|
|
1748
1748
|
author: fieldsAuthor,
|
|
1749
1749
|
date,
|
|
1750
|
+
externalLink,
|
|
1750
1751
|
...simpleFields
|
|
1751
1752
|
} = fields;
|
|
1752
1753
|
const articleType = resolveLink(context, sys.id, fieldsArticleType);
|
|
1753
1754
|
const tags = fieldsTags?.map((tag) => resolveLink(context, sys.id, tag));
|
|
1754
1755
|
const primaryTag = tags?.[0] ?? void 0;
|
|
1755
1756
|
const author = fieldsAuthor ? resolveLink(context, sys.id, fieldsAuthor) : void 0;
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
primaryTag,
|
|
1765
|
-
articleType,
|
|
1766
|
-
date,
|
|
1767
|
-
author
|
|
1768
|
-
}
|
|
1769
|
-
);
|
|
1757
|
+
const href = externalLink ? externalLink : context.urlCalculators.article(articleType.slug, fields.slug, primaryTag?.slug);
|
|
1758
|
+
return createInternalLink(sys.id, simpleFields, context, href, "Article", {
|
|
1759
|
+
tags,
|
|
1760
|
+
primaryTag,
|
|
1761
|
+
articleType,
|
|
1762
|
+
date,
|
|
1763
|
+
author
|
|
1764
|
+
});
|
|
1770
1765
|
}
|
|
1771
1766
|
function baseArticleTypeLinkConverter(context, entry) {
|
|
1772
1767
|
const { sys, fields } = entry;
|