@se-studio/contentful-rest-api 1.0.45 → 1.0.47
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/CHANGELOG.md +416 -0
- package/dist/api/article-type.d.ts +37 -0
- package/dist/api/article-type.d.ts.map +1 -0
- package/dist/api/article-type.js +134 -0
- package/dist/api/article-type.js.map +1 -0
- package/dist/api/article.d.ts +32 -0
- package/dist/api/article.d.ts.map +1 -0
- package/dist/api/article.js +43 -0
- package/dist/api/article.js.map +1 -0
- package/dist/api/asset.d.ts +28 -0
- package/dist/api/asset.d.ts.map +1 -0
- package/dist/api/asset.js +55 -0
- package/dist/api/asset.js.map +1 -0
- package/dist/api/context.d.ts +24 -0
- package/dist/api/context.d.ts.map +1 -0
- package/dist/api/context.js +62 -0
- package/dist/api/context.js.map +1 -0
- package/dist/api/custom-type.d.ts +37 -0
- package/dist/api/custom-type.d.ts.map +1 -0
- package/dist/api/custom-type.js +44 -0
- package/dist/api/custom-type.js.map +1 -0
- package/dist/api/helpers.d.ts +73 -0
- package/dist/api/helpers.d.ts.map +1 -0
- package/dist/api/helpers.js +296 -0
- package/dist/api/helpers.js.map +1 -0
- package/dist/api/index.d.ts +22 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +28 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/links.d.ts +109 -0
- package/dist/api/links.d.ts.map +1 -0
- package/dist/api/links.js +199 -0
- package/dist/api/links.js.map +1 -0
- package/dist/api/page.d.ts +33 -0
- package/dist/api/page.d.ts.map +1 -0
- package/dist/api/page.js +40 -0
- package/dist/api/page.js.map +1 -0
- package/dist/api/person.d.ts +37 -0
- package/dist/api/person.d.ts.map +1 -0
- package/dist/api/person.js +134 -0
- package/dist/api/person.js.map +1 -0
- package/dist/api/preview.d.ts +55 -0
- package/dist/api/preview.d.ts.map +1 -0
- package/dist/api/preview.js +160 -0
- package/dist/api/preview.js.map +1 -0
- package/dist/api/related-articles.d.ts +22 -0
- package/dist/api/related-articles.d.ts.map +1 -0
- package/dist/api/related-articles.js +82 -0
- package/dist/api/related-articles.js.map +1 -0
- package/dist/api/server-asset.d.ts +40 -0
- package/dist/api/server-asset.d.ts.map +1 -0
- package/dist/api/server-asset.js +65 -0
- package/dist/api/server-asset.js.map +1 -0
- package/dist/api/sitemap.d.ts +131 -0
- package/dist/api/sitemap.d.ts.map +1 -0
- package/dist/api/sitemap.js +199 -0
- package/dist/api/sitemap.js.map +1 -0
- package/dist/api/tag.d.ts +37 -0
- package/dist/api/tag.d.ts.map +1 -0
- package/dist/api/tag.js +131 -0
- package/dist/api/tag.js.map +1 -0
- package/dist/api/template.d.ts +49 -0
- package/dist/api/template.d.ts.map +1 -0
- package/dist/api/template.js +88 -0
- package/dist/api/template.js.map +1 -0
- package/dist/api/types.d.ts +98 -0
- package/dist/api/types.d.ts.map +1 -0
- package/dist/api/types.js +2 -0
- package/dist/api/types.js.map +1 -0
- package/dist/baseTypes/baseAlternatePageContent.d.ts +24 -0
- package/dist/baseTypes/baseAlternatePageContent.d.ts.map +1 -0
- package/dist/baseTypes/baseAlternatePageContent.js +2 -0
- package/dist/baseTypes/baseAlternatePageContent.js.map +1 -0
- package/dist/baseTypes/baseArticle.d.ts +179 -0
- package/dist/baseTypes/baseArticle.d.ts.map +1 -0
- package/dist/baseTypes/baseArticle.js +2 -0
- package/dist/baseTypes/baseArticle.js.map +1 -0
- package/dist/baseTypes/baseArticleType.d.ts +156 -0
- package/dist/baseTypes/baseArticleType.d.ts.map +1 -0
- package/dist/baseTypes/baseArticleType.js +2 -0
- package/dist/baseTypes/baseArticleType.js.map +1 -0
- package/dist/baseTypes/baseBanner.d.ts +76 -0
- package/dist/baseTypes/baseBanner.d.ts.map +1 -0
- package/dist/baseTypes/baseBanner.js +2 -0
- package/dist/baseTypes/baseBanner.js.map +1 -0
- package/dist/baseTypes/baseCollection.d.ts +132 -0
- package/dist/baseTypes/baseCollection.d.ts.map +1 -0
- package/dist/baseTypes/baseCollection.js +2 -0
- package/dist/baseTypes/baseCollection.js.map +1 -0
- package/dist/baseTypes/baseComponent.d.ts +130 -0
- package/dist/baseTypes/baseComponent.d.ts.map +1 -0
- package/dist/baseTypes/baseComponent.js +2 -0
- package/dist/baseTypes/baseComponent.js.map +1 -0
- package/dist/baseTypes/baseCustomType.d.ts +126 -0
- package/dist/baseTypes/baseCustomType.d.ts.map +1 -0
- package/dist/baseTypes/baseCustomType.js +2 -0
- package/dist/baseTypes/baseCustomType.js.map +1 -0
- package/dist/baseTypes/baseExternalComponent.d.ts +66 -0
- package/dist/baseTypes/baseExternalComponent.d.ts.map +1 -0
- package/dist/baseTypes/baseExternalComponent.js +2 -0
- package/dist/baseTypes/baseExternalComponent.js.map +1 -0
- package/dist/baseTypes/baseExternalVideo.d.ts +85 -0
- package/dist/baseTypes/baseExternalVideo.d.ts.map +1 -0
- package/dist/baseTypes/baseExternalVideo.js +2 -0
- package/dist/baseTypes/baseExternalVideo.js.map +1 -0
- package/dist/baseTypes/baseLink.d.ts +90 -0
- package/dist/baseTypes/baseLink.d.ts.map +1 -0
- package/dist/baseTypes/baseLink.js +2 -0
- package/dist/baseTypes/baseLink.js.map +1 -0
- package/dist/baseTypes/baseMedia.d.ts +92 -0
- package/dist/baseTypes/baseMedia.d.ts.map +1 -0
- package/dist/baseTypes/baseMedia.js +2 -0
- package/dist/baseTypes/baseMedia.js.map +1 -0
- package/dist/baseTypes/baseNavigation.d.ts +36 -0
- package/dist/baseTypes/baseNavigation.d.ts.map +1 -0
- package/dist/baseTypes/baseNavigation.js +2 -0
- package/dist/baseTypes/baseNavigation.js.map +1 -0
- package/dist/baseTypes/baseNavigationItem.d.ts +96 -0
- package/dist/baseTypes/baseNavigationItem.d.ts.map +1 -0
- package/dist/baseTypes/baseNavigationItem.js +2 -0
- package/dist/baseTypes/baseNavigationItem.js.map +1 -0
- package/dist/baseTypes/basePage.d.ts +120 -0
- package/dist/baseTypes/basePage.d.ts.map +1 -0
- package/dist/baseTypes/basePage.js +2 -0
- package/dist/baseTypes/basePage.js.map +1 -0
- package/dist/baseTypes/basePageTest.d.ts +66 -0
- package/dist/baseTypes/basePageTest.d.ts.map +1 -0
- package/dist/baseTypes/basePageTest.js +2 -0
- package/dist/baseTypes/basePageTest.js.map +1 -0
- package/dist/baseTypes/basePageVariant.d.ts +123 -0
- package/dist/baseTypes/basePageVariant.d.ts.map +1 -0
- package/dist/baseTypes/basePageVariant.js +2 -0
- package/dist/baseTypes/basePageVariant.js.map +1 -0
- package/dist/baseTypes/basePerson.d.ts +111 -0
- package/dist/baseTypes/basePerson.d.ts.map +1 -0
- package/dist/baseTypes/basePerson.js +2 -0
- package/dist/baseTypes/basePerson.js.map +1 -0
- package/dist/baseTypes/baseSchema.d.ts +18 -0
- package/dist/baseTypes/baseSchema.d.ts.map +1 -0
- package/dist/baseTypes/baseSchema.js +2 -0
- package/dist/baseTypes/baseSchema.js.map +1 -0
- package/dist/baseTypes/baseShared.d.ts +30 -0
- package/dist/baseTypes/baseShared.d.ts.map +1 -0
- package/dist/baseTypes/baseShared.js +2 -0
- package/dist/baseTypes/baseShared.js.map +1 -0
- package/dist/baseTypes/baseTag.d.ts +108 -0
- package/dist/baseTypes/baseTag.d.ts.map +1 -0
- package/dist/baseTypes/baseTag.js +2 -0
- package/dist/baseTypes/baseTag.js.map +1 -0
- package/dist/baseTypes/baseTagType.d.ts +11 -0
- package/dist/baseTypes/baseTagType.d.ts.map +1 -0
- package/dist/baseTypes/baseTagType.js +2 -0
- package/dist/baseTypes/baseTagType.js.map +1 -0
- package/dist/baseTypes/baseTemplate.d.ts +55 -0
- package/dist/baseTypes/baseTemplate.d.ts.map +1 -0
- package/dist/baseTypes/baseTemplate.js +2 -0
- package/dist/baseTypes/baseTemplate.js.map +1 -0
- package/dist/client.d.ts +143 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +268 -0
- package/dist/client.js.map +1 -0
- package/dist/converters/article.d.ts +42 -0
- package/dist/converters/article.d.ts.map +1 -0
- package/dist/converters/article.js +220 -0
- package/dist/converters/article.js.map +1 -0
- package/dist/converters/asset.d.ts +22 -0
- package/dist/converters/asset.d.ts.map +1 -0
- package/dist/converters/asset.js +282 -0
- package/dist/converters/asset.js.map +1 -0
- package/dist/converters/collection.d.ts +26 -0
- package/dist/converters/collection.d.ts.map +1 -0
- package/dist/converters/collection.js +50 -0
- package/dist/converters/collection.js.map +1 -0
- package/dist/converters/component.d.ts +26 -0
- package/dist/converters/component.d.ts.map +1 -0
- package/dist/converters/component.js +54 -0
- package/dist/converters/component.js.map +1 -0
- package/dist/converters/customType.d.ts +24 -0
- package/dist/converters/customType.d.ts.map +1 -0
- package/dist/converters/customType.js +71 -0
- package/dist/converters/customType.js.map +1 -0
- package/dist/converters/externalComponent.d.ts +22 -0
- package/dist/converters/externalComponent.d.ts.map +1 -0
- package/dist/converters/externalComponent.js +34 -0
- package/dist/converters/externalComponent.js.map +1 -0
- package/dist/converters/helpers.d.ts +116 -0
- package/dist/converters/helpers.d.ts.map +1 -0
- package/dist/converters/helpers.js +128 -0
- package/dist/converters/helpers.js.map +1 -0
- package/dist/converters/iconCollector.d.ts +65 -0
- package/dist/converters/iconCollector.d.ts.map +1 -0
- package/dist/converters/iconCollector.js +282 -0
- package/dist/converters/iconCollector.js.map +1 -0
- package/dist/converters/index.d.ts +18 -0
- package/dist/converters/index.d.ts.map +1 -0
- package/dist/converters/index.js +18 -0
- package/dist/converters/index.js.map +1 -0
- package/dist/converters/link.d.ts +11 -0
- package/dist/converters/link.d.ts.map +1 -0
- package/dist/converters/link.js +96 -0
- package/dist/converters/link.js.map +1 -0
- package/dist/converters/navigationItem.d.ts +11 -0
- package/dist/converters/navigationItem.d.ts.map +1 -0
- package/dist/converters/navigationItem.js +73 -0
- package/dist/converters/navigationItem.js.map +1 -0
- package/dist/converters/page.d.ts +44 -0
- package/dist/converters/page.d.ts.map +1 -0
- package/dist/converters/page.js +121 -0
- package/dist/converters/page.js.map +1 -0
- package/dist/converters/person.d.ts +40 -0
- package/dist/converters/person.d.ts.map +1 -0
- package/dist/converters/person.js +109 -0
- package/dist/converters/person.js.map +1 -0
- package/dist/converters/resolver.d.ts +29 -0
- package/dist/converters/resolver.d.ts.map +1 -0
- package/dist/converters/resolver.js +317 -0
- package/dist/converters/resolver.js.map +1 -0
- package/dist/converters/schema.d.ts +14 -0
- package/dist/converters/schema.d.ts.map +1 -0
- package/dist/converters/schema.js +18 -0
- package/dist/converters/schema.js.map +1 -0
- package/dist/converters/svgProcessor.d.ts +23 -0
- package/dist/converters/svgProcessor.d.ts.map +1 -0
- package/dist/converters/svgProcessor.js +47 -0
- package/dist/converters/svgProcessor.js.map +1 -0
- package/dist/converters/tag.d.ts +25 -0
- package/dist/converters/tag.d.ts.map +1 -0
- package/dist/converters/tag.js +98 -0
- package/dist/converters/tag.js.map +1 -0
- package/dist/converters/template.d.ts +26 -0
- package/dist/converters/template.d.ts.map +1 -0
- package/dist/converters/template.js +44 -0
- package/dist/converters/template.js.map +1 -0
- package/dist/index.d.ts +28 -718
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +37 -3602
- package/dist/index.js.map +1 -1
- package/dist/revalidation/handlers.d.ts +52 -0
- package/dist/revalidation/handlers.d.ts.map +1 -0
- package/dist/revalidation/handlers.js +130 -0
- package/dist/revalidation/handlers.js.map +1 -0
- package/dist/revalidation/index.d.ts +3 -0
- package/dist/revalidation/index.d.ts.map +1 -0
- package/dist/revalidation/index.js +4 -0
- package/dist/revalidation/index.js.map +1 -0
- package/dist/revalidation/nextjs-route.d.ts +31 -0
- package/dist/revalidation/nextjs-route.d.ts.map +1 -0
- package/dist/revalidation/nextjs-route.js +34 -0
- package/dist/revalidation/nextjs-route.js.map +1 -0
- package/dist/revalidation/route.d.ts +3 -0
- package/dist/revalidation/route.d.ts.map +1 -0
- package/dist/revalidation/route.js +97 -0
- package/dist/revalidation/route.js.map +1 -0
- package/dist/revalidation/server-utils.d.ts +22 -0
- package/dist/revalidation/server-utils.d.ts.map +1 -0
- package/dist/revalidation/server-utils.js +41 -0
- package/dist/revalidation/server-utils.js.map +1 -0
- package/dist/revalidation/tags.d.ts +81 -0
- package/dist/revalidation/tags.d.ts.map +1 -0
- package/dist/revalidation/tags.js +117 -0
- package/dist/revalidation/tags.js.map +1 -0
- package/dist/revalidation/utils.d.ts +21 -0
- package/dist/revalidation/utils.d.ts.map +1 -0
- package/dist/revalidation/utils.js +51 -0
- package/dist/revalidation/utils.js.map +1 -0
- package/dist/server.d.ts +7 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +10 -0
- package/dist/server.js.map +1 -0
- package/dist/types.d.ts +67 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/arrayUtils.d.ts +3 -0
- package/dist/utils/arrayUtils.d.ts.map +1 -0
- package/dist/utils/arrayUtils.js +12 -0
- package/dist/utils/arrayUtils.js.map +1 -0
- package/dist/utils/dateUtils.d.ts +9 -0
- package/dist/utils/dateUtils.d.ts.map +1 -0
- package/dist/utils/dateUtils.js +26 -0
- package/dist/utils/dateUtils.js.map +1 -0
- package/dist/utils/errors.d.ts +56 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +100 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/index.d.ts +8 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +8 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/json-utils.d.ts +17 -0
- package/dist/utils/json-utils.d.ts.map +1 -0
- package/dist/utils/json-utils.js +43 -0
- package/dist/utils/json-utils.js.map +1 -0
- package/dist/utils/retry.d.ts +112 -0
- package/dist/utils/retry.d.ts.map +1 -0
- package/dist/utils/retry.js +221 -0
- package/dist/utils/retry.js.map +1 -0
- package/package.json +12 -6
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { contentfulAllArticleLinks, contentfulAllArticleTypeLinks, contentfulAllPageLinks, contentfulAllPersonLinks, contentfulAllTagLinks, } from './links';
|
|
2
|
+
// ============================================================================
|
|
3
|
+
// Sitemap Entry Helpers
|
|
4
|
+
// ============================================================================
|
|
5
|
+
/**
|
|
6
|
+
* Helper function to convert internal links to sitemap entries.
|
|
7
|
+
* Filters to only include indexed and non-hidden entries.
|
|
8
|
+
*
|
|
9
|
+
* @param links - Array of internal links with metadata
|
|
10
|
+
* @param sitemapConfig - Configuration for priority and change frequency
|
|
11
|
+
* @returns Array of sitemap entries
|
|
12
|
+
*/
|
|
13
|
+
function linksToSitemapEntries(links, sitemapConfig) {
|
|
14
|
+
return links
|
|
15
|
+
.filter((link) => link.indexed !== false && link.hidden !== true && link.href)
|
|
16
|
+
.map((link) => ({
|
|
17
|
+
url: link.href,
|
|
18
|
+
lastModified: link.lastModified,
|
|
19
|
+
changeFrequency: sitemapConfig?.changeFrequency,
|
|
20
|
+
priority: sitemapConfig?.priority,
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
// ============================================================================
|
|
24
|
+
// Sitemap Entry Fetchers
|
|
25
|
+
// ============================================================================
|
|
26
|
+
/**
|
|
27
|
+
* Fetches all page sitemap entries from Contentful.
|
|
28
|
+
* Only includes pages that are indexed and not hidden.
|
|
29
|
+
*
|
|
30
|
+
* @param context - Converter context
|
|
31
|
+
* @param config - Contentful configuration
|
|
32
|
+
* @param sitemapConfig - Optional sitemap configuration (priority, changeFrequency)
|
|
33
|
+
* @param options - Fetch options (locale, preview, caching, etc.)
|
|
34
|
+
* @returns Promise resolving to CmsResponse with array of sitemap entries
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* const { data: entries } = await contentfulPageSitemapEntries(
|
|
39
|
+
* context,
|
|
40
|
+
* config,
|
|
41
|
+
* { priority: 0.8, changeFrequency: 'weekly' },
|
|
42
|
+
* { next: { revalidate: 3600 } }
|
|
43
|
+
* );
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export async function contentfulPageSitemapEntries(context, config, sitemapConfig, options) {
|
|
47
|
+
const response = await contentfulAllPageLinks(context, config, options);
|
|
48
|
+
return {
|
|
49
|
+
data: linksToSitemapEntries(response.data, sitemapConfig),
|
|
50
|
+
errors: response.errors,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Fetches all article sitemap entries from Contentful.
|
|
55
|
+
* Only includes articles that are indexed and not hidden.
|
|
56
|
+
*
|
|
57
|
+
* @param context - Converter context
|
|
58
|
+
* @param config - Contentful configuration
|
|
59
|
+
* @param sitemapConfig - Optional sitemap configuration (priority, changeFrequency)
|
|
60
|
+
* @param options - Fetch options (locale, preview, caching, etc.)
|
|
61
|
+
* @returns Promise resolving to CmsResponse with array of sitemap entries
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```ts
|
|
65
|
+
* const { data: entries } = await contentfulArticleSitemapEntries(
|
|
66
|
+
* context,
|
|
67
|
+
* config,
|
|
68
|
+
* { priority: 0.6, changeFrequency: 'monthly' },
|
|
69
|
+
* { next: { revalidate: 3600 } }
|
|
70
|
+
* );
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export async function contentfulArticleSitemapEntries(context, config, sitemapConfig, options) {
|
|
74
|
+
const response = await contentfulAllArticleLinks(context, config, options);
|
|
75
|
+
return {
|
|
76
|
+
data: linksToSitemapEntries(response.data, sitemapConfig),
|
|
77
|
+
errors: response.errors,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Fetches all article type sitemap entries from Contentful.
|
|
82
|
+
* Only includes article types that are indexed and not hidden.
|
|
83
|
+
*
|
|
84
|
+
* @param context - Converter context
|
|
85
|
+
* @param config - Contentful configuration
|
|
86
|
+
* @param sitemapConfig - Optional sitemap configuration (priority, changeFrequency)
|
|
87
|
+
* @param options - Fetch options (locale, preview, caching, etc.)
|
|
88
|
+
* @returns Promise resolving to CmsResponse with array of sitemap entries
|
|
89
|
+
*/
|
|
90
|
+
export async function contentfulArticleTypeSitemapEntries(context, config, sitemapConfig, options) {
|
|
91
|
+
const response = await contentfulAllArticleTypeLinks(context, config, options);
|
|
92
|
+
return {
|
|
93
|
+
data: linksToSitemapEntries(response.data, sitemapConfig),
|
|
94
|
+
errors: response.errors,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Fetches all tag sitemap entries from Contentful.
|
|
99
|
+
* Only includes tags that are indexed and not hidden.
|
|
100
|
+
*
|
|
101
|
+
* @param context - Converter context
|
|
102
|
+
* @param config - Contentful configuration
|
|
103
|
+
* @param sitemapConfig - Optional sitemap configuration (priority, changeFrequency)
|
|
104
|
+
* @param options - Fetch options (locale, preview, caching, etc.)
|
|
105
|
+
* @returns Promise resolving to CmsResponse with array of sitemap entries
|
|
106
|
+
*/
|
|
107
|
+
export async function contentfulTagSitemapEntries(context, config, sitemapConfig, options) {
|
|
108
|
+
const response = await contentfulAllTagLinks(context, config, options);
|
|
109
|
+
return {
|
|
110
|
+
data: linksToSitemapEntries(response.data, sitemapConfig),
|
|
111
|
+
errors: response.errors,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Fetches all person sitemap entries from Contentful.
|
|
116
|
+
* Only includes people that are indexed and not hidden.
|
|
117
|
+
*
|
|
118
|
+
* @param context - Converter context
|
|
119
|
+
* @param config - Contentful configuration
|
|
120
|
+
* @param sitemapConfig - Optional sitemap configuration (priority, changeFrequency)
|
|
121
|
+
* @param options - Fetch options (locale, preview, caching, etc.)
|
|
122
|
+
* @returns Promise resolving to CmsResponse with array of sitemap entries
|
|
123
|
+
*/
|
|
124
|
+
export async function contentfulPersonSitemapEntries(context, config, sitemapConfig, options) {
|
|
125
|
+
const response = await contentfulAllPersonLinks(context, config, options);
|
|
126
|
+
return {
|
|
127
|
+
data: linksToSitemapEntries(response.data, sitemapConfig),
|
|
128
|
+
errors: response.errors,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
// ============================================================================
|
|
132
|
+
// Sitemap Registry Functions
|
|
133
|
+
// ============================================================================
|
|
134
|
+
/**
|
|
135
|
+
* Collects sitemap entries from multiple providers.
|
|
136
|
+
* This allows projects to register custom content types for sitemap generation.
|
|
137
|
+
*
|
|
138
|
+
* @param context - Converter context
|
|
139
|
+
* @param config - Contentful configuration
|
|
140
|
+
* @param sitemapConfig - Configuration with array of provider functions
|
|
141
|
+
* @param options - Fetch options (locale, preview, caching, etc.)
|
|
142
|
+
* @returns Promise resolving to CmsResponse with all sitemap entries combined
|
|
143
|
+
*
|
|
144
|
+
* @example
|
|
145
|
+
* ```ts
|
|
146
|
+
* const { data: entries, errors } = await getAllSitemapEntries(
|
|
147
|
+
* context,
|
|
148
|
+
* config,
|
|
149
|
+
* {
|
|
150
|
+
* providers: [
|
|
151
|
+
* (ctx, cfg, opts) => contentfulPageSitemapEntries(ctx, cfg, { priority: 0.8 }, opts),
|
|
152
|
+
* (ctx, cfg, opts) => contentfulArticleSitemapEntries(ctx, cfg, { priority: 0.6 }, opts),
|
|
153
|
+
* // Custom content type provider
|
|
154
|
+
* async (ctx, cfg, opts) => {
|
|
155
|
+
* const links = await fetchCustomContentLinks(ctx, cfg, opts);
|
|
156
|
+
* return { data: links.map(l => ({ url: l.href, lastModified: l.lastModified })), errors: [] };
|
|
157
|
+
* },
|
|
158
|
+
* ],
|
|
159
|
+
* },
|
|
160
|
+
* { next: { revalidate: 3600 } }
|
|
161
|
+
* );
|
|
162
|
+
* ```
|
|
163
|
+
*/
|
|
164
|
+
export async function getAllSitemapEntries(context, config, sitemapConfig, options) {
|
|
165
|
+
const allEntries = [];
|
|
166
|
+
const allErrors = [];
|
|
167
|
+
// Fetch from all providers in parallel for better performance
|
|
168
|
+
const results = await Promise.all(sitemapConfig.providers.map((provider) => provider(context, config, options)));
|
|
169
|
+
// Combine all results
|
|
170
|
+
for (const result of results) {
|
|
171
|
+
allEntries.push(...result.data);
|
|
172
|
+
allErrors.push(...result.errors);
|
|
173
|
+
}
|
|
174
|
+
return { data: allEntries, errors: allErrors };
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Creates a sitemap entry provider with pre-configured options.
|
|
178
|
+
* Useful for creating providers with specific priority and changeFrequency settings.
|
|
179
|
+
*
|
|
180
|
+
* @param fetcher - The sitemap entry fetcher function to wrap
|
|
181
|
+
* @param sitemapConfig - Configuration for priority and change frequency
|
|
182
|
+
* @returns A sitemap entry provider function
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
* ```ts
|
|
186
|
+
* const pageProvider = createSitemapProvider(
|
|
187
|
+
* contentfulPageSitemapEntries,
|
|
188
|
+
* { priority: 0.8, changeFrequency: 'weekly' }
|
|
189
|
+
* );
|
|
190
|
+
*
|
|
191
|
+
* const { data: entries } = await getAllSitemapEntries(context, config, {
|
|
192
|
+
* providers: [pageProvider, articleProvider],
|
|
193
|
+
* });
|
|
194
|
+
* ```
|
|
195
|
+
*/
|
|
196
|
+
export function createSitemapProvider(fetcher, sitemapConfig) {
|
|
197
|
+
return (context, config, options) => fetcher(context, config, sitemapConfig, options);
|
|
198
|
+
}
|
|
199
|
+
//# sourceMappingURL=sitemap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sitemap.js","sourceRoot":"","sources":["../../src/api/sitemap.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,yBAAyB,EACzB,6BAA6B,EAC7B,sBAAsB,EACtB,wBAAwB,EACxB,qBAAqB,GACtB,MAAM,SAAS,CAAC;AAQjB,+EAA+E;AAC/E,wBAAwB;AACxB,+EAA+E;AAE/E;;;;;;;GAOG;AACH,SAAS,qBAAqB,CAC5B,KAAsB,EACtB,aAAwC;IAExC,OAAO,KAAK;SACT,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,KAAK,KAAK,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI,IAAI,IAAI,CAAC,IAAI,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AO,CAAC,CAAC,CAC9E,CAAC;IAEF,sBAAsB;IACtB,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,UAAU,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;QAChC,SAAS,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;AACjD,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,qBAAqB,CACnC,OAK0C,EAC1C,aAAuC;IAEvC,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC;AACxF,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { IBaseTag } from '@se-studio/core-data-types';
|
|
2
|
+
import type { BaseConverterContext } from '../converters/helpers';
|
|
3
|
+
import type { CmsResponse, ContentfulConfig, FetchOptions } from '../types';
|
|
4
|
+
export interface TagFetchOptions extends FetchOptions {
|
|
5
|
+
customType?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Fetches a tag from Contentful by slug
|
|
9
|
+
*
|
|
10
|
+
* @param context - Converter context
|
|
11
|
+
* @param config - Contentful configuration
|
|
12
|
+
* @param slug - Tag slug to fetch
|
|
13
|
+
* @param options - Fetch options (locale, preview, caching, etc.)
|
|
14
|
+
* @returns Promise resolving to IBaseTag or null if not found
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* const tag = await contentfulTagRest(
|
|
19
|
+
* context,
|
|
20
|
+
* {
|
|
21
|
+
* spaceId: process.env.CONTENTFUL_SPACE_ID!,
|
|
22
|
+
* accessToken: process.env.CONTENTFUL_ACCESS_TOKEN!,
|
|
23
|
+
* },
|
|
24
|
+
* 'my-tag',
|
|
25
|
+
* {
|
|
26
|
+
* locale: 'en-US',
|
|
27
|
+
* cache: {
|
|
28
|
+
* tags: ['my-tag'],
|
|
29
|
+
* revalidate: 3600
|
|
30
|
+
* },
|
|
31
|
+
* customType: 'topics' // Optional custom type
|
|
32
|
+
* }
|
|
33
|
+
* );
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare function contentfulTagRest(context: BaseConverterContext, config: ContentfulConfig, slug: string, options: TagFetchOptions): Promise<CmsResponse<IBaseTag | null>>;
|
|
37
|
+
//# sourceMappingURL=tag.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tag.d.ts","sourceRoot":"","sources":["../../src/api/tag.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAK3D,OAAO,KAAK,EAAE,oBAAoB,EAAoB,MAAM,uBAAuB,CAAC;AAGpF,OAAO,KAAK,EAAY,WAAW,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAKtF,MAAM,WAAW,eAAgB,SAAQ,YAAY;IACnD,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,oBAAoB,EAC7B,MAAM,EAAE,gBAAgB,EACxB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,WAAW,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC,CA2HvC"}
|
package/dist/api/tag.js
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { getContentfulClient } from '../client';
|
|
2
|
+
import { processIconsForSprite } from '../converters/iconCollector';
|
|
3
|
+
import { getCacheTags } from '../revalidation/utils';
|
|
4
|
+
import { withRetry } from '../utils';
|
|
5
|
+
import { convertAllAssets, convertAllIncludes, convertAllRawAssets } from './helpers';
|
|
6
|
+
/**
|
|
7
|
+
* Fetches a tag from Contentful by slug
|
|
8
|
+
*
|
|
9
|
+
* @param context - Converter context
|
|
10
|
+
* @param config - Contentful configuration
|
|
11
|
+
* @param slug - Tag slug to fetch
|
|
12
|
+
* @param options - Fetch options (locale, preview, caching, etc.)
|
|
13
|
+
* @returns Promise resolving to IBaseTag or null if not found
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* const tag = await contentfulTagRest(
|
|
18
|
+
* context,
|
|
19
|
+
* {
|
|
20
|
+
* spaceId: process.env.CONTENTFUL_SPACE_ID!,
|
|
21
|
+
* accessToken: process.env.CONTENTFUL_ACCESS_TOKEN!,
|
|
22
|
+
* },
|
|
23
|
+
* 'my-tag',
|
|
24
|
+
* {
|
|
25
|
+
* locale: 'en-US',
|
|
26
|
+
* cache: {
|
|
27
|
+
* tags: ['my-tag'],
|
|
28
|
+
* revalidate: 3600
|
|
29
|
+
* },
|
|
30
|
+
* customType: 'topics' // Optional custom type
|
|
31
|
+
* }
|
|
32
|
+
* );
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export async function contentfulTagRest(context, config, slug, options) {
|
|
36
|
+
const client = getContentfulClient(config, options.preview);
|
|
37
|
+
// Set cache tags for this request
|
|
38
|
+
const tagCacheTags = getCacheTags('tag', slug, options?.preview);
|
|
39
|
+
const customTypeCacheTags = options?.customType
|
|
40
|
+
? getCacheTags('customType', options.customType, options?.preview)
|
|
41
|
+
: [];
|
|
42
|
+
const requestOptions = {
|
|
43
|
+
...options,
|
|
44
|
+
next: {
|
|
45
|
+
...options?.next,
|
|
46
|
+
tags: [...tagCacheTags, ...customTypeCacheTags],
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
const fetchFn = async () => {
|
|
50
|
+
const tagPromise = client.getEntries({
|
|
51
|
+
content_type: 'tag',
|
|
52
|
+
'fields.slug': slug,
|
|
53
|
+
include: 10,
|
|
54
|
+
locale: options?.locale,
|
|
55
|
+
limit: 1,
|
|
56
|
+
}, requestOptions);
|
|
57
|
+
const customTypePromise = options?.customType
|
|
58
|
+
? client.getEntries({
|
|
59
|
+
content_type: 'customType',
|
|
60
|
+
'fields.slug': options.customType,
|
|
61
|
+
include: 10,
|
|
62
|
+
locale: options?.locale,
|
|
63
|
+
limit: 1,
|
|
64
|
+
}, requestOptions)
|
|
65
|
+
: Promise.resolve(null);
|
|
66
|
+
const [tagResponse, customTypeResponse] = await Promise.all([tagPromise, customTypePromise]);
|
|
67
|
+
const tagEntry = tagResponse.items[0];
|
|
68
|
+
if (!tagEntry || !tagEntry.fields) {
|
|
69
|
+
return { data: null, errors: [] };
|
|
70
|
+
}
|
|
71
|
+
const customTypeEntry = customTypeResponse?.items[0];
|
|
72
|
+
try {
|
|
73
|
+
const assets = convertAllAssets(tagResponse, context);
|
|
74
|
+
const rawAssets = convertAllRawAssets(tagResponse);
|
|
75
|
+
const includes = convertAllIncludes(tagResponse);
|
|
76
|
+
if (customTypeResponse) {
|
|
77
|
+
const customAssets = convertAllAssets(customTypeResponse, context);
|
|
78
|
+
const customRawAssets = convertAllRawAssets(customTypeResponse);
|
|
79
|
+
const customIncludes = convertAllIncludes(customTypeResponse);
|
|
80
|
+
for (const [key, value] of customAssets)
|
|
81
|
+
assets.set(key, value);
|
|
82
|
+
for (const [key, value] of customRawAssets)
|
|
83
|
+
rawAssets.set(key, value);
|
|
84
|
+
for (const [key, value] of customIncludes)
|
|
85
|
+
includes.set(key, value);
|
|
86
|
+
}
|
|
87
|
+
const fullContext = {
|
|
88
|
+
...context,
|
|
89
|
+
includes,
|
|
90
|
+
assets,
|
|
91
|
+
rawAssets,
|
|
92
|
+
errors: [],
|
|
93
|
+
};
|
|
94
|
+
const converted = context.tagResolver(fullContext, tagEntry, customTypeEntry);
|
|
95
|
+
// Process icons if the result has an icons field
|
|
96
|
+
if (converted?.icons && converted.icons.length > 0) {
|
|
97
|
+
const processedIcons = await processIconsForSprite(converted.icons);
|
|
98
|
+
converted.icons = processedIcons.length > 0 ? processedIcons : undefined;
|
|
99
|
+
}
|
|
100
|
+
// Log errors in production
|
|
101
|
+
if (fullContext.errors.length > 0 &&
|
|
102
|
+
typeof process !== 'undefined' &&
|
|
103
|
+
process.env?.NODE_ENV === 'production') {
|
|
104
|
+
console.error(`CMS conversion errors for tag:`, {
|
|
105
|
+
entryId: tagEntry.sys.id,
|
|
106
|
+
slug,
|
|
107
|
+
errors: fullContext.errors,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
return { data: converted, errors: fullContext.errors };
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
const entryId = tagEntry?.sys.id || 'unknown';
|
|
114
|
+
const entryType = tagEntry?.sys.contentType?.sys?.id;
|
|
115
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown conversion error';
|
|
116
|
+
const cmsError = {
|
|
117
|
+
entryId,
|
|
118
|
+
entryType,
|
|
119
|
+
message: errorMessage,
|
|
120
|
+
error,
|
|
121
|
+
};
|
|
122
|
+
return { data: null, errors: [cmsError] };
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
// Apply retry logic if configured
|
|
126
|
+
if (options?.retry) {
|
|
127
|
+
return await withRetry(fetchFn, options.retry);
|
|
128
|
+
}
|
|
129
|
+
return await fetchFn();
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=tag.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tag.js","sourceRoot":"","sources":["../../src/api/tag.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAEhD,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAA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C,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,0BAA0B,CAAC;YAEzF,MAAM,QAAQ,GAAa;gBACzB,OAAO;gBACP,SAAS;gBACT,OAAO,EAAE,YAAY;gBACrB,KAAK;aACN,CAAC;YAEF,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5C,CAAC;IACH,CAAC,CAAC;IAEF,kCAAkC;IAClC,IAAI,OAAO,EAAE,KAAK,EAAE,CAAC;QACnB,OAAO,MAAM,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IACjD,CAAC;IAED,OAAO,MAAM,OAAO,EAAE,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { INavigation, ISvgImage, ITyped } from '@se-studio/core-data-types';
|
|
2
|
+
import type { BaseConverterContext } from '../converters/helpers';
|
|
3
|
+
import type { CmsResponse, ContentfulConfig, FetchOptions } from '../types';
|
|
4
|
+
/**
|
|
5
|
+
* Fetched template data structure
|
|
6
|
+
* Extends the resolved template with id and label for direct fetching
|
|
7
|
+
*/
|
|
8
|
+
export interface IFetchedTemplate {
|
|
9
|
+
id: string;
|
|
10
|
+
cmsLabel: string;
|
|
11
|
+
preContent: ReadonlyArray<ITyped>;
|
|
12
|
+
postContent: ReadonlyArray<ITyped>;
|
|
13
|
+
menu?: INavigation;
|
|
14
|
+
footer?: INavigation;
|
|
15
|
+
backgroundColour?: string;
|
|
16
|
+
textColour?: string;
|
|
17
|
+
stickyNav: boolean;
|
|
18
|
+
icons?: ReadonlyArray<ISvgImage>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Fetches a template from Contentful by cmsLabel
|
|
22
|
+
*
|
|
23
|
+
* @param context - Converter context
|
|
24
|
+
* @param config - Contentful configuration
|
|
25
|
+
* @param cmsLabel - Template cmsLabel to fetch (e.g., '404')
|
|
26
|
+
* @param options - Fetch options (locale, preview, caching, etc.)
|
|
27
|
+
* @returns Promise resolving to IFetchedTemplate or null if not found
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* const template = await contentfulTemplateRest(
|
|
32
|
+
* context,
|
|
33
|
+
* {
|
|
34
|
+
* spaceId: process.env.CONTENTFUL_SPACE_ID!,
|
|
35
|
+
* accessToken: process.env.CONTENTFUL_ACCESS_TOKEN!,
|
|
36
|
+
* },
|
|
37
|
+
* '404',
|
|
38
|
+
* {
|
|
39
|
+
* locale: 'en-US',
|
|
40
|
+
* cache: {
|
|
41
|
+
* tags: ['template#404'],
|
|
42
|
+
* revalidate: 3600
|
|
43
|
+
* }
|
|
44
|
+
* }
|
|
45
|
+
* );
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare function contentfulTemplateRest(context: BaseConverterContext, config: ContentfulConfig, cmsLabel: string, options: FetchOptions): Promise<CmsResponse<IFetchedTemplate | null>>;
|
|
49
|
+
//# sourceMappingURL=template.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../../src/api/template.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAGjF,OAAO,KAAK,EAAE,oBAAoB,EAAoB,MAAM,uBAAuB,CAAC;AAIpF,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAI5E;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAClC,WAAW,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACnC,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;CAClC;AA4DD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,oBAAoB,EAC7B,MAAM,EAAE,gBAAgB,EACxB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,YAAY,GACpB,OAAO,CAAC,WAAW,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC,CAc/C"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { collectIconsFromContent, collectIconsFromNavigation } from '../converters/iconCollector';
|
|
2
|
+
import { resolveNavigation } from '../converters/navigationItem';
|
|
3
|
+
import { resolvePageContent } from '../converters/resolver';
|
|
4
|
+
import { fetchSingleEntity } from './helpers';
|
|
5
|
+
/**
|
|
6
|
+
* Converts a template entry to IFetchedTemplate
|
|
7
|
+
*/
|
|
8
|
+
function templateConverter(context, entry) {
|
|
9
|
+
const { fields, sys } = entry;
|
|
10
|
+
const id = sys.id;
|
|
11
|
+
// Resolve content arrays
|
|
12
|
+
const preContent = fields.preContent
|
|
13
|
+
?.map((content) => resolvePageContent(context, id, content))
|
|
14
|
+
.filter((item) => item !== null) ?? [];
|
|
15
|
+
const postContent = fields.postContent
|
|
16
|
+
?.map((content) => resolvePageContent(context, id, content))
|
|
17
|
+
.filter((item) => item !== null) ?? [];
|
|
18
|
+
// Resolve navigation entries
|
|
19
|
+
const menu = fields.menu ? resolveNavigation(context, fields.menu) : undefined;
|
|
20
|
+
const footer = fields.footer ? resolveNavigation(context, fields.footer) : undefined;
|
|
21
|
+
// Check for sticky nav flag
|
|
22
|
+
const stickyNav = fields.flags?.includes('Sticky nav') ?? false;
|
|
23
|
+
// Collect all SVG icons from template content and navigation
|
|
24
|
+
const contentIcons = collectIconsFromContent([...preContent, ...postContent]);
|
|
25
|
+
const menuIcons = collectIconsFromNavigation(menu);
|
|
26
|
+
const footerIcons = collectIconsFromNavigation(footer);
|
|
27
|
+
// Merge and deduplicate icons by ID
|
|
28
|
+
const allIcons = [...contentIcons, ...menuIcons, ...footerIcons];
|
|
29
|
+
const seenIconIds = new Set();
|
|
30
|
+
const icons = allIcons.filter((icon) => {
|
|
31
|
+
if (seenIconIds.has(icon.id)) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
seenIconIds.add(icon.id);
|
|
35
|
+
return true;
|
|
36
|
+
});
|
|
37
|
+
return {
|
|
38
|
+
id,
|
|
39
|
+
cmsLabel: fields.cmsLabel,
|
|
40
|
+
preContent,
|
|
41
|
+
postContent,
|
|
42
|
+
menu,
|
|
43
|
+
footer,
|
|
44
|
+
backgroundColour: fields.backgroundColour,
|
|
45
|
+
textColour: fields.textColour,
|
|
46
|
+
stickyNav,
|
|
47
|
+
icons: icons.length > 0 ? icons : undefined,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Fetches a template from Contentful by cmsLabel
|
|
52
|
+
*
|
|
53
|
+
* @param context - Converter context
|
|
54
|
+
* @param config - Contentful configuration
|
|
55
|
+
* @param cmsLabel - Template cmsLabel to fetch (e.g., '404')
|
|
56
|
+
* @param options - Fetch options (locale, preview, caching, etc.)
|
|
57
|
+
* @returns Promise resolving to IFetchedTemplate or null if not found
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```ts
|
|
61
|
+
* const template = await contentfulTemplateRest(
|
|
62
|
+
* context,
|
|
63
|
+
* {
|
|
64
|
+
* spaceId: process.env.CONTENTFUL_SPACE_ID!,
|
|
65
|
+
* accessToken: process.env.CONTENTFUL_ACCESS_TOKEN!,
|
|
66
|
+
* },
|
|
67
|
+
* '404',
|
|
68
|
+
* {
|
|
69
|
+
* locale: 'en-US',
|
|
70
|
+
* cache: {
|
|
71
|
+
* tags: ['template#404'],
|
|
72
|
+
* revalidate: 3600
|
|
73
|
+
* }
|
|
74
|
+
* }
|
|
75
|
+
* );
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
export async function contentfulTemplateRest(context, config, cmsLabel, options) {
|
|
79
|
+
return fetchSingleEntity(context, config, {
|
|
80
|
+
contentType: 'template',
|
|
81
|
+
cacheTagType: 'template',
|
|
82
|
+
cacheTagIdentifier: cmsLabel,
|
|
83
|
+
query: { 'fields.cmsLabel': cmsLabel },
|
|
84
|
+
resolver: (ctx, entry) => templateConverter(ctx, entry),
|
|
85
|
+
errorLogContext: { cmsLabel },
|
|
86
|
+
}, options);
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../src/api/template.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,uBAAuB,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AAClG,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAoB9C;;GAEG;AACH,SAAS,iBAAiB,CACxB,OAAyB,EACzB,KAAgE;IAEhE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,KAAK,CAAC;IAC9B,MAAM,EAAE,GAAG,GAAG,CAAC,EAAE,CAAC;IAElB,yBAAyB;IACzB,MAAM,UAAU,GACd,MAAM,CAAC,UAAU;QACf,EAAE,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,kBAAkB,CAAC,OAAO,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;SAC3D,MAAM,CAAC,CAAC,IAAI,EAAkB,EAAE,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC;IAE3D,MAAM,WAAW,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C,EAAE,CAAC,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,EAAE;QACF,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,UAAU;QACV,WAAW;QACX,IAAI;QACJ,MAAM;QACN,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;QACzC,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,SAAS;QACT,KAAK,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;KAC5C,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,OAA6B,EAC7B,MAAwB,EACxB,QAAgB,EAChB,OAAqB;IAErB,OAAO,iBAAiB,CACtB,OAAO,EACP,MAAM,EACN;QACE,WAAW,EAAE,UAAU;QACvB,YAAY,EAAE,UAAU;QACxB,kBAAkB,EAAE,QAAQ;QAC5B,KAAK,EAAE,EAAE,iBAAiB,EAAE,QAAQ,EAAE;QACtC,QAAQ,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,iBAAiB,CAAC,GAAG,EAAE,KAAK,CAAC;QACvD,eAAe,EAAE,EAAE,QAAQ,EAAE;KAC9B,EACD,OAAO,CACR,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import type { Document } from '@contentful/rich-text-types';
|
|
2
|
+
import type { IBaseArticle, IBaseArticleType, IBasePage, IBaseTag, IInternalLink, INavigation, INavigationItem, IVisual } from '@se-studio/core-data-types';
|
|
3
|
+
import type { Entry, EntrySkeletonType } from 'contentful';
|
|
4
|
+
import type { BaseConverterContext, ConverterContext } from '../converters/helpers';
|
|
5
|
+
import type { IContentfulPerson } from '../converters/person';
|
|
6
|
+
import type { CmsResponse, ContentfulConfig, FetchOptions } from '../types';
|
|
7
|
+
export type DefaultChainModifier = 'WITHOUT_LINK_RESOLUTION';
|
|
8
|
+
export interface IContentfulRichText {
|
|
9
|
+
json: Document;
|
|
10
|
+
customStyles?: ReadonlyArray<string> | null;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Change frequency hints for sitemap entries.
|
|
14
|
+
* These are hints to search engine crawlers about how often content changes.
|
|
15
|
+
*/
|
|
16
|
+
export type SitemapChangeFrequency = 'always' | 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly' | 'never';
|
|
17
|
+
/**
|
|
18
|
+
* A single sitemap entry representing a URL to be indexed.
|
|
19
|
+
* Compatible with Next.js MetadataRoute.Sitemap format.
|
|
20
|
+
*/
|
|
21
|
+
export interface ISitemapEntry {
|
|
22
|
+
/** Full URL path (from href) */
|
|
23
|
+
url: string;
|
|
24
|
+
/** Last modified date from Contentful sys.updatedAt */
|
|
25
|
+
lastModified?: Date;
|
|
26
|
+
/** Change frequency hint for crawlers */
|
|
27
|
+
changeFrequency?: SitemapChangeFrequency;
|
|
28
|
+
/** Priority hint (0.0-1.0) */
|
|
29
|
+
priority?: number;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Configuration for sitemap entries of a specific content type.
|
|
33
|
+
* Allows setting default priority and change frequency for all entries of that type.
|
|
34
|
+
*/
|
|
35
|
+
export interface SitemapContentTypeConfig {
|
|
36
|
+
/** Default priority for this content type (0.0-1.0) */
|
|
37
|
+
priority?: number;
|
|
38
|
+
/** Default change frequency for this content type */
|
|
39
|
+
changeFrequency?: SitemapChangeFrequency;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Provider function type for fetching sitemap entries.
|
|
43
|
+
* Projects can implement custom providers for additional content types.
|
|
44
|
+
*/
|
|
45
|
+
export type SitemapEntryProvider = (context: BaseConverterContext, config: ContentfulConfig, options: FetchOptions) => Promise<CmsResponse<ISitemapEntry[]>>;
|
|
46
|
+
/**
|
|
47
|
+
* Configuration for collecting sitemap entries from multiple sources.
|
|
48
|
+
*/
|
|
49
|
+
export interface SitemapConfig {
|
|
50
|
+
/** Array of provider functions that fetch sitemap entries */
|
|
51
|
+
providers: SitemapEntryProvider[];
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Options for filtering related articles
|
|
55
|
+
*/
|
|
56
|
+
export interface RelatedArticlesOptions {
|
|
57
|
+
/** Articles to exclude from results */
|
|
58
|
+
excludeArticleIds?: string[];
|
|
59
|
+
/** Filter to articles matching any of these article types */
|
|
60
|
+
articleTypeIds?: string[];
|
|
61
|
+
/** Filter/rank by tags - articles with matching tags are ranked higher */
|
|
62
|
+
tagIds?: string[];
|
|
63
|
+
/** Filter/rank by authors - articles with matching authors are ranked higher */
|
|
64
|
+
authorIds?: string[];
|
|
65
|
+
/** Only include articles published before this date */
|
|
66
|
+
before?: Date;
|
|
67
|
+
/** Only include articles published after this date */
|
|
68
|
+
after?: Date;
|
|
69
|
+
/** Maximum number of results to return (undefined = return all matches) */
|
|
70
|
+
count?: number;
|
|
71
|
+
}
|
|
72
|
+
export type ResolvedEntry = IBasePage | IBaseArticle | IBaseArticleType | IBaseTag | INavigation | INavigationItem | IInternalLink | unknown | IContentfulPerson;
|
|
73
|
+
export type PossibleResolvedEntry = {
|
|
74
|
+
id: string;
|
|
75
|
+
type: string;
|
|
76
|
+
entry: Entry<EntrySkeletonType, DefaultChainModifier, string>;
|
|
77
|
+
resolved?: ResolvedEntry;
|
|
78
|
+
};
|
|
79
|
+
export type Converter<TEntry extends EntrySkeletonType, TResult> = (entry: Entry<TEntry, DefaultChainModifier, string>, includes: Map<string, PossibleResolvedEntry>, assets: Map<string, IVisual>) => TResult;
|
|
80
|
+
/**
|
|
81
|
+
* Configuration for fetching a single entity from Contentful.
|
|
82
|
+
* Used by the generic fetchSingleEntity helper.
|
|
83
|
+
*/
|
|
84
|
+
export interface SingleEntityFetchConfig<TEntry extends EntrySkeletonType, TResult> {
|
|
85
|
+
/** Contentful content type ID */
|
|
86
|
+
contentType: string;
|
|
87
|
+
/** Cache tag type for revalidation */
|
|
88
|
+
cacheTagType: string;
|
|
89
|
+
/** Cache tag identifier (usually slug) */
|
|
90
|
+
cacheTagIdentifier: string;
|
|
91
|
+
/** Query parameters for getEntries */
|
|
92
|
+
query: Record<string, unknown>;
|
|
93
|
+
/** Resolver function to convert the entry */
|
|
94
|
+
resolver: (context: ConverterContext, entry: Entry<TEntry, DefaultChainModifier, string>) => TResult;
|
|
95
|
+
/** Context for error logging */
|
|
96
|
+
errorLogContext: Record<string, unknown>;
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/api/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,KAAK,EACV,YAAY,EACZ,gBAAgB,EAChB,SAAS,EACT,QAAQ,EACR,aAAa,EACb,WAAW,EACX,eAAe,EACf,OAAO,EACR,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,KAAK,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACpF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE5E,MAAM,MAAM,oBAAoB,GAAG,yBAAyB,CAAC;AAE7D,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,QAAQ,CAAC;IACf,YAAY,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;CAC7C;AAMD;;;GAGG;AACH,MAAM,MAAM,sBAAsB,GAC9B,QAAQ,GACR,QAAQ,GACR,OAAO,GACP,QAAQ,GACR,SA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