@sitecore-content-sdk/nextjs 1.4.0-canary.21 → 1.4.0-canary.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.
|
@@ -104,8 +104,11 @@ class SitecoreNextjsClient extends client_1.SitecoreClient {
|
|
|
104
104
|
* @returns {Promise<StaticParams[]>} Array of `{ site, locale, path }` entries for `generateStaticParams`.
|
|
105
105
|
*/
|
|
106
106
|
getAppRouterStaticParams(sites, languages, fetchOptions) {
|
|
107
|
+
const _super = Object.create(null, {
|
|
108
|
+
getPagePaths: { get: () => super.getPagePaths }
|
|
109
|
+
});
|
|
107
110
|
return __awaiter(this, void 0, void 0, function* () {
|
|
108
|
-
const staticPaths = yield
|
|
111
|
+
const staticPaths = yield _super.getPagePaths.call(this, sites, languages, fetchOptions);
|
|
109
112
|
const params = new Array();
|
|
110
113
|
staticPaths.map((path) => {
|
|
111
114
|
var _a;
|
|
@@ -120,6 +123,29 @@ class SitecoreNextjsClient extends client_1.SitecoreClient {
|
|
|
120
123
|
return params;
|
|
121
124
|
});
|
|
122
125
|
}
|
|
126
|
+
/**
|
|
127
|
+
* Retrieves the static paths for pages based on the given languages.
|
|
128
|
+
* @param {string[]} sites - An array of site names to fetch routes for.
|
|
129
|
+
* @param {string[]} [languages] - An optional array of language codes to generate paths for.
|
|
130
|
+
* @param {FetchOptions} [fetchOptions] - Additional fetch options.
|
|
131
|
+
* @returns {Promise<StaticPath[]>} A promise that resolves to an array of static paths.
|
|
132
|
+
*/
|
|
133
|
+
getPagePaths(sites, languages, fetchOptions) {
|
|
134
|
+
const _super = Object.create(null, {
|
|
135
|
+
getPagePaths: { get: () => super.getPagePaths }
|
|
136
|
+
});
|
|
137
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
138
|
+
var _a;
|
|
139
|
+
const staticPaths = yield _super.getPagePaths.call(this, sites, languages, fetchOptions);
|
|
140
|
+
if (!((_a = this.initOptions.multisite) === null || _a === void 0 ? void 0 : _a.enabled)) {
|
|
141
|
+
// remove _site_ segments when multisite is disabled
|
|
142
|
+
staticPaths.map((path) => {
|
|
143
|
+
path.params.path = (0, site_1.normalizeSiteRewrite)(path.params.path.join('/')).split('/');
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
return staticPaths;
|
|
147
|
+
});
|
|
148
|
+
}
|
|
123
149
|
/**
|
|
124
150
|
* Parses components from nextjs component map and layoutData, executes getServerProps/getStaticProps methods
|
|
125
151
|
* and returns resulting props from components
|
|
@@ -101,8 +101,11 @@ export class SitecoreNextjsClient extends SitecoreClient {
|
|
|
101
101
|
* @returns {Promise<StaticParams[]>} Array of `{ site, locale, path }` entries for `generateStaticParams`.
|
|
102
102
|
*/
|
|
103
103
|
getAppRouterStaticParams(sites, languages, fetchOptions) {
|
|
104
|
+
const _super = Object.create(null, {
|
|
105
|
+
getPagePaths: { get: () => super.getPagePaths }
|
|
106
|
+
});
|
|
104
107
|
return __awaiter(this, void 0, void 0, function* () {
|
|
105
|
-
const staticPaths = yield
|
|
108
|
+
const staticPaths = yield _super.getPagePaths.call(this, sites, languages, fetchOptions);
|
|
106
109
|
const params = new Array();
|
|
107
110
|
staticPaths.map((path) => {
|
|
108
111
|
var _a;
|
|
@@ -117,6 +120,29 @@ export class SitecoreNextjsClient extends SitecoreClient {
|
|
|
117
120
|
return params;
|
|
118
121
|
});
|
|
119
122
|
}
|
|
123
|
+
/**
|
|
124
|
+
* Retrieves the static paths for pages based on the given languages.
|
|
125
|
+
* @param {string[]} sites - An array of site names to fetch routes for.
|
|
126
|
+
* @param {string[]} [languages] - An optional array of language codes to generate paths for.
|
|
127
|
+
* @param {FetchOptions} [fetchOptions] - Additional fetch options.
|
|
128
|
+
* @returns {Promise<StaticPath[]>} A promise that resolves to an array of static paths.
|
|
129
|
+
*/
|
|
130
|
+
getPagePaths(sites, languages, fetchOptions) {
|
|
131
|
+
const _super = Object.create(null, {
|
|
132
|
+
getPagePaths: { get: () => super.getPagePaths }
|
|
133
|
+
});
|
|
134
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
135
|
+
var _a;
|
|
136
|
+
const staticPaths = yield _super.getPagePaths.call(this, sites, languages, fetchOptions);
|
|
137
|
+
if (!((_a = this.initOptions.multisite) === null || _a === void 0 ? void 0 : _a.enabled)) {
|
|
138
|
+
// remove _site_ segments when multisite is disabled
|
|
139
|
+
staticPaths.map((path) => {
|
|
140
|
+
path.params.path = normalizeSiteRewrite(path.params.path.join('/')).split('/');
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
return staticPaths;
|
|
144
|
+
});
|
|
145
|
+
}
|
|
120
146
|
/**
|
|
121
147
|
* Parses components from nextjs component map and layoutData, executes getServerProps/getStaticProps methods
|
|
122
148
|
* and returns resulting props from components
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sitecore-content-sdk/nextjs",
|
|
3
|
-
"version": "1.4.0-canary.
|
|
3
|
+
"version": "1.4.0-canary.22",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -91,8 +91,8 @@
|
|
|
91
91
|
},
|
|
92
92
|
"dependencies": {
|
|
93
93
|
"@babel/parser": "^7.27.2",
|
|
94
|
-
"@sitecore-content-sdk/core": "1.4.0-canary.
|
|
95
|
-
"@sitecore-content-sdk/react": "1.4.0-canary.
|
|
94
|
+
"@sitecore-content-sdk/core": "1.4.0-canary.22",
|
|
95
|
+
"@sitecore-content-sdk/react": "1.4.0-canary.22",
|
|
96
96
|
"recast": "^0.23.11",
|
|
97
97
|
"regex-parser": "^2.3.1",
|
|
98
98
|
"sync-disk-cache": "^2.1.0"
|
|
@@ -176,7 +176,7 @@
|
|
|
176
176
|
},
|
|
177
177
|
"description": "",
|
|
178
178
|
"types": "types/index.d.ts",
|
|
179
|
-
"gitHead": "
|
|
179
|
+
"gitHead": "3f1ff6ee5ee6c9d615609fd9913a3b1aca03715e",
|
|
180
180
|
"files": [
|
|
181
181
|
"dist",
|
|
182
182
|
"types",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { StaticPath } from '@sitecore-content-sdk/core';
|
|
1
2
|
import { FetchOptions, Page, PageOptions, SitecoreClient, SitecoreClientInit } from '@sitecore-content-sdk/core/client';
|
|
2
3
|
import { ComponentPropsCollection, NextjsContentSdkComponent } from '../sharedTypes/component-props';
|
|
3
4
|
import { GetServerSidePropsContext, GetStaticPropsContext, PreviewData } from 'next';
|
|
@@ -5,14 +6,20 @@ import { LayoutServiceData } from '@sitecore-content-sdk/core/layout';
|
|
|
5
6
|
import { ComponentPropsService } from '../services/component-props-service';
|
|
6
7
|
import { ComponentMap } from '@sitecore-content-sdk/react';
|
|
7
8
|
import { StaticParams } from './models';
|
|
9
|
+
import { SitecoreConfig } from '../config';
|
|
10
|
+
/**
|
|
11
|
+
* Init options for Sitecore Client that allows you to override services too
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
export type SitecoreNextjsClientInit = SitecoreClientInit & Pick<SitecoreConfig, 'multisite'>;
|
|
8
15
|
/**
|
|
9
16
|
* The SitecoreNextjsClient class extends the SitecoreClient class to provide additional functionality for Next.js.
|
|
10
17
|
* @public
|
|
11
18
|
*/
|
|
12
19
|
export declare class SitecoreNextjsClient extends SitecoreClient {
|
|
13
|
-
protected initOptions:
|
|
20
|
+
protected initOptions: SitecoreNextjsClientInit;
|
|
14
21
|
protected componentPropsService: ComponentPropsService;
|
|
15
|
-
constructor(initOptions:
|
|
22
|
+
constructor(initOptions: SitecoreNextjsClientInit);
|
|
16
23
|
/**
|
|
17
24
|
* Gets site name based on the provided path
|
|
18
25
|
* @param {string | string[]} path path to get site name from
|
|
@@ -54,6 +61,14 @@ export declare class SitecoreNextjsClient extends SitecoreClient {
|
|
|
54
61
|
* @returns {Promise<StaticParams[]>} Array of `{ site, locale, path }` entries for `generateStaticParams`.
|
|
55
62
|
*/
|
|
56
63
|
getAppRouterStaticParams(sites: string[], languages?: string[], fetchOptions?: FetchOptions): Promise<StaticParams[]>;
|
|
64
|
+
/**
|
|
65
|
+
* Retrieves the static paths for pages based on the given languages.
|
|
66
|
+
* @param {string[]} sites - An array of site names to fetch routes for.
|
|
67
|
+
* @param {string[]} [languages] - An optional array of language codes to generate paths for.
|
|
68
|
+
* @param {FetchOptions} [fetchOptions] - Additional fetch options.
|
|
69
|
+
* @returns {Promise<StaticPath[]>} A promise that resolves to an array of static paths.
|
|
70
|
+
*/
|
|
71
|
+
getPagePaths(sites: string[], languages?: string[], fetchOptions?: FetchOptions): Promise<StaticPath[]>;
|
|
57
72
|
/**
|
|
58
73
|
* Parses components from nextjs component map and layoutData, executes getServerProps/getStaticProps methods
|
|
59
74
|
* and returns resulting props from components
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sitecore-nextjs-client.d.ts","sourceRoot":"","sources":["../../src/client/sitecore-nextjs-client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,IAAI,EACJ,WAAW,EACX,cAAc,EACd,kBAAkB,EACnB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,wBAAwB,EAExB,yBAAyB,EAC1B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AACrF,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAU5E,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"sitecore-nextjs-client.d.ts","sourceRoot":"","sources":["../../src/client/sitecore-nextjs-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,E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