@enonic/nextjs-adapter 0.11.0 → 0.12.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/UrlProcessor.d.ts +1 -0
- package/UrlProcessor.js +6 -2
- package/guillotine/fetchContent.js +5 -0
- package/package.json +8 -8
package/UrlProcessor.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export declare class UrlProcessor {
|
|
|
9
9
|
private static IMG_ATMT_REGEXP;
|
|
10
10
|
private static endSlashPattern;
|
|
11
11
|
private static startSlashPattern;
|
|
12
|
+
private static localhostPattern;
|
|
12
13
|
private static siteKey;
|
|
13
14
|
static process(url: string, meta: MetaData): string;
|
|
14
15
|
static setSiteKey(key: string): void;
|
package/UrlProcessor.js
CHANGED
|
@@ -25,8 +25,11 @@ export class UrlProcessor {
|
|
|
25
25
|
return ((_a = linkData.find(data => data.ref === ref)) === null || _a === void 0 ? void 0 : _a.image) !== null;
|
|
26
26
|
}
|
|
27
27
|
static stripApiUrl(url, apiUrl) {
|
|
28
|
-
|
|
29
|
-
const
|
|
28
|
+
// normalise localhost-127.0.0.1 if present in urls
|
|
29
|
+
const normalUrl = url.replace(this.localhostPattern, '127.0.0.1');
|
|
30
|
+
const normalApiUrl = apiUrl.replace(this.localhostPattern, '127.0.0.1');
|
|
31
|
+
const common = commonChars(normalUrl, normalApiUrl);
|
|
32
|
+
const remaining = common.length > 0 ? normalUrl.substring(common.length) : normalUrl;
|
|
30
33
|
return (remaining.length > 0 && remaining.charAt(0) === '/') ? remaining.substring(1) : remaining;
|
|
31
34
|
}
|
|
32
35
|
static isPageUrl(url) {
|
|
@@ -50,5 +53,6 @@ UrlProcessor.MACRO_ATTR = 'data-macro-ref';
|
|
|
50
53
|
UrlProcessor.IMG_ATMT_REGEXP = /_\/image\/|_\/attachment\//;
|
|
51
54
|
UrlProcessor.endSlashPattern = /\/+$/;
|
|
52
55
|
UrlProcessor.startSlashPattern = /^\/+/;
|
|
56
|
+
UrlProcessor.localhostPattern = /localhost/;
|
|
53
57
|
UrlProcessor.setSiteKey(SITE_KEY);
|
|
54
58
|
export const getUrl = UrlProcessor.process.bind(UrlProcessor);
|
|
@@ -533,6 +533,7 @@ export const buildContentFetcher = (config) => {
|
|
|
533
533
|
const { type, components, _path } = metaResult.meta || {};
|
|
534
534
|
contentPath = _path || '';
|
|
535
535
|
if (metaResult.error) {
|
|
536
|
+
console.error(metaResult.error);
|
|
536
537
|
return errorResponse(metaResult.error.code, metaResult.error.message, requestType, renderMode, contentApiUrl, xpBaseUrl, contentPath);
|
|
537
538
|
}
|
|
538
539
|
if (!metaResult.meta) {
|
|
@@ -586,6 +587,10 @@ export const buildContentFetcher = (config) => {
|
|
|
586
587
|
// /////////////// SECOND GUILLOTINE CALL FOR DATA //////////////////////
|
|
587
588
|
const contentResults = yield fetchContentData(contentApiUrl, contentPath, query, variables, headers);
|
|
588
589
|
// ///////////////////////////////////////////////////////////////////////////
|
|
590
|
+
if (contentResults.error) {
|
|
591
|
+
console.error(contentResults.error);
|
|
592
|
+
return errorResponse(contentResults.error.code, contentResults.error.message, requestType, renderMode, contentApiUrl, xpBaseUrl, contentPath);
|
|
593
|
+
}
|
|
589
594
|
// Apply processors to every component
|
|
590
595
|
const datas = yield applyProcessors(allDescriptors, contentResults, context);
|
|
591
596
|
// Unwind the data back to components
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@enonic/nextjs-adapter",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"publishConfig": {
|
|
@@ -14,20 +14,20 @@
|
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"html-react-parser": "^3.0.4",
|
|
17
|
-
"next": "^13.0.
|
|
17
|
+
"next": "^13.0.7",
|
|
18
18
|
"react": "^18.2.0",
|
|
19
19
|
"react-dom": "^18.2.0",
|
|
20
20
|
"unescape": "^1.0.1"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@enonic/eslint-config": "^0.1.0",
|
|
24
|
-
"@types/node": "^18.11.
|
|
25
|
-
"@types/react": "^18.0.
|
|
24
|
+
"@types/node": "^18.11.17",
|
|
25
|
+
"@types/react": "^18.0.26",
|
|
26
26
|
"@types/react-dom": "^18.0.9",
|
|
27
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
28
|
-
"@typescript-eslint/parser": "^5.
|
|
29
|
-
"eslint": "^8.
|
|
27
|
+
"@typescript-eslint/eslint-plugin": "^5.46.1",
|
|
28
|
+
"@typescript-eslint/parser": "^5.46.1",
|
|
29
|
+
"eslint": "^8.30.0",
|
|
30
30
|
"eslint-plugin-react": "^7.31.11",
|
|
31
|
-
"typescript": "^4.9.
|
|
31
|
+
"typescript": "^4.9.4"
|
|
32
32
|
}
|
|
33
33
|
}
|