@se-studio/contentful-rest-api 1.1.2 → 1.3.0
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 +68 -0
- package/README.md +7 -1
- package/dist/api/context.d.ts.map +1 -1
- package/dist/api/context.js +2 -0
- package/dist/api/context.js.map +1 -1
- package/dist/api/index.d.ts +2 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +2 -0
- package/dist/api/index.js.map +1 -1
- package/dist/api/redirects.d.ts +16 -0
- package/dist/api/redirects.d.ts.map +1 -0
- package/dist/api/redirects.js +106 -0
- package/dist/api/redirects.js.map +1 -0
- package/dist/api/related-articles.d.ts +6 -1
- package/dist/api/related-articles.d.ts.map +1 -1
- package/dist/api/related-articles.js +66 -19
- package/dist/api/related-articles.js.map +1 -1
- package/dist/api/types.d.ts +15 -3
- package/dist/api/types.d.ts.map +1 -1
- package/dist/baseTypes/baseRedirect.d.ts +126 -0
- package/dist/baseTypes/baseRedirect.d.ts.map +1 -0
- package/dist/baseTypes/baseRedirect.js +2 -0
- package/dist/baseTypes/baseRedirect.js.map +1 -0
- package/dist/converters/helpers.d.ts +1 -0
- package/dist/converters/helpers.d.ts.map +1 -1
- package/dist/converters/helpers.js.map +1 -1
- package/dist/converters/index.d.ts +1 -0
- package/dist/converters/index.d.ts.map +1 -1
- package/dist/converters/index.js +1 -0
- package/dist/converters/index.js.map +1 -1
- package/dist/converters/redirect.d.ts +20 -0
- package/dist/converters/redirect.d.ts.map +1 -0
- package/dist/converters/redirect.js +103 -0
- package/dist/converters/redirect.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/revalidation/handlers.d.ts.map +1 -1
- package/dist/revalidation/handlers.js +6 -1
- package/dist/revalidation/handlers.js.map +1 -1
- package/dist/revalidation/tags.d.ts +6 -0
- package/dist/revalidation/tags.d.ts.map +1 -1
- package/dist/revalidation/tags.js +9 -0
- package/dist/revalidation/tags.js.map +1 -1
- package/dist/utils/redirectMap.d.ts +25 -0
- package/dist/utils/redirectMap.d.ts.map +1 -0
- package/dist/utils/redirectMap.js +39 -0
- package/dist/utils/redirectMap.js.map +1 -0
- package/docs/llms.md +9 -3
- package/package.json +2 -2
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure helper that turns a list of IRedirect (from Contentful) into the simple
|
|
3
|
+
* map used by middleware at runtime or baked into a static module at build.
|
|
4
|
+
*
|
|
5
|
+
* - Filters out inactive redirects.
|
|
6
|
+
* - Prefers explicit statusCode; defaults to 301.
|
|
7
|
+
* - Does light normalization (ensures leading /; the app's trailingSlash: true
|
|
8
|
+
* convention means callers should store rules with trailing slashes for
|
|
9
|
+
* internal paths).
|
|
10
|
+
*
|
|
11
|
+
* This is intentionally side-effect free and safe to run in a Next.js build
|
|
12
|
+
* script or edge middleware context.
|
|
13
|
+
*/
|
|
14
|
+
export function buildRedirectMap(redirects) {
|
|
15
|
+
const map = {};
|
|
16
|
+
if (!redirects || redirects.length === 0) {
|
|
17
|
+
return map;
|
|
18
|
+
}
|
|
19
|
+
for (const r of redirects) {
|
|
20
|
+
if (r.active === false)
|
|
21
|
+
continue;
|
|
22
|
+
let from = r.fromPath || '';
|
|
23
|
+
if (!from)
|
|
24
|
+
continue;
|
|
25
|
+
if (!from.startsWith('/'))
|
|
26
|
+
from = `/${from}`;
|
|
27
|
+
// Basic self-loop guard (don't bake a rule that points to itself)
|
|
28
|
+
const to = r.to || '';
|
|
29
|
+
if (!to)
|
|
30
|
+
continue;
|
|
31
|
+
if (to === from)
|
|
32
|
+
continue;
|
|
33
|
+
const status = (r.statusCode ?? 301);
|
|
34
|
+
// Last one wins if duplicates (editors should avoid); keeps it simple.
|
|
35
|
+
map[from] = { to, status };
|
|
36
|
+
}
|
|
37
|
+
return map;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=redirectMap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redirectMap.js","sourceRoot":"","sources":["../../src/utils/redirectMap.ts"],"names":[],"mappings":"AAaA;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,gBAAgB,CAAC,SAAyC;IACxE,MAAM,GAAG,GAAgB,EAAE,CAAC;IAE5B,IAAI,CAAC,SAAS,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzC,OAAO,GAAG,CAAC;IACb,CAAC;IAED,KAAK,MAAM,CAAC,IAAI,SAAS,EAAE,CAAC;QAC1B,IAAI,CAAC,CAAC,MAAM,KAAK,KAAK;YAAE,SAAS;QAEjC,IAAI,IAAI,GAAG,CAAC,CAAC,QAAQ,IAAI,EAAE,CAAC;QAC5B,IAAI,CAAC,IAAI;YAAE,SAAS;QACpB,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;YAAE,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;QAE7C,kEAAkE;QAClE,MAAM,EAAE,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC;QACtB,IAAI,CAAC,EAAE;YAAE,SAAS;QAClB,IAAI,EAAE,KAAK,IAAI;YAAE,SAAS;QAE1B,MAAM,MAAM,GAAG,CAAC,CAAC,CAAC,UAAU,IAAI,GAAG,CAA+B,CAAC;QAEnE,uEAAuE;QACvE,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC;IAC7B,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/docs/llms.md
CHANGED
|
@@ -70,13 +70,19 @@ import { filterRelatedArticles } from '@se-studio/contentful-rest-api';
|
|
|
70
70
|
|
|
71
71
|
const related = filterRelatedArticles(allArticleLinks, {
|
|
72
72
|
tagIds: ['tag-entry-id-1', 'tag-entry-id-2'], // OR filter — must match at least one
|
|
73
|
-
|
|
73
|
+
tagSlugs: ['topic-a'], // slugs also supported (combined with OR)
|
|
74
|
+
articleTypeSlugs: ['resources/news'], // or articleTypeIds
|
|
75
|
+
authorSlugs: ['alice'], // or authorIds
|
|
76
|
+
strictAuthorMatch: true, // hard filter (exclude non-matches) instead of boost
|
|
77
|
+
tagTypeSlugs: ['condition'], // hard filter on any tag's tagType
|
|
74
78
|
excludeArticleIds: [currentArticle.id],
|
|
75
|
-
|
|
79
|
+
before: new Date('2025-01-01'),
|
|
80
|
+
count: 3, // undefined = all matches after sort
|
|
81
|
+
allowUnindexed: true,
|
|
76
82
|
});
|
|
77
83
|
```
|
|
78
84
|
|
|
79
|
-
When
|
|
85
|
+
When tag criteria are set, articles must match at least one (OR). More distinct matching tags → higher rank (then newest date). `strictAuthorMatch` turns author criteria into an exclude filter (key for person-scoped full lists). Use via `getAllArticleLinks({ articleTypeSlugs, strictAuthorMatch, ... })` in core-ui helpers for News Grids / Publications Lists without duplicating filter logic. Direct import is server-only (main barrel of the package pulls server-only transitive deps via enrichers).
|
|
80
86
|
|
|
81
87
|
## Sitemap Helpers
|
|
82
88
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@se-studio/contentful-rest-api",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Type-safe Contentful REST API client with caching and rate limiting for Next.js applications",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@contentful/rich-text-types": "^17.2.7",
|
|
52
52
|
"contentful": "^11.12.3",
|
|
53
53
|
"server-only": "0.0.1",
|
|
54
|
-
"@se-studio/core-data-types": "1.
|
|
54
|
+
"@se-studio/core-data-types": "1.2.0"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
57
|
"next": ">=15.5.0"
|