@enonic/nextjs-adapter 2.0.0-B3 → 2.0.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/guillotine/fetchContent.d.ts +3 -2
- package/guillotine/fetchContent.js +6 -3
- package/package.json +6 -6
- package/utils.d.ts +1 -1
- package/utils.js +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MetaData, PageComponent } from './getMetaData';
|
|
2
2
|
import { ContentPathItem, Context, LocaleProjectConfig } from '../utils';
|
|
3
|
-
import { GetStaticPropsResult } from 'next';
|
|
3
|
+
import { GetServerSidePropsResult, GetStaticPropsResult } from 'next';
|
|
4
4
|
type Result = {
|
|
5
5
|
error?: {
|
|
6
6
|
code: string;
|
|
@@ -42,7 +42,8 @@ export declare const fetchGuillotine: (contentApiUrl: string, body: ContentApiBa
|
|
|
42
42
|
* @returns FetchContentResult object: {data?: T, error?: {code, message}}
|
|
43
43
|
*/
|
|
44
44
|
export declare const fetchContent: ContentFetcher;
|
|
45
|
-
export declare function createResponse(props: FetchContentResult, context?: Context): GetStaticPropsResult<FetchContentResult>;
|
|
45
|
+
export declare function createResponse(props: FetchContentResult, context?: Context, isStatic?: true): GetStaticPropsResult<FetchContentResult>;
|
|
46
|
+
export declare function createResponse(props: FetchContentResult, context?: Context, isStatic?: false): GetServerSidePropsResult<FetchContentResult>;
|
|
46
47
|
export declare function fetchContentPathsForAllLocales(path: string, query?: string, countPerLocale?: number): Promise<ContentPathItem[]>;
|
|
47
48
|
export declare function fetchContentPathsForLocale(path: string, config: LocaleProjectConfig, query?: string, count?: number): Promise<ContentPathItem[]>;
|
|
48
49
|
export {};
|
|
@@ -747,7 +747,7 @@ const buildContentFetcher = (config) => {
|
|
|
747
747
|
* @returns FetchContentResult object: {data?: T, error?: {code, message}}
|
|
748
748
|
*/
|
|
749
749
|
export const fetchContent = buildContentFetcher(Object.assign(Object.assign({}, adapterConstants), { componentRegistry: ComponentRegistry }));
|
|
750
|
-
export function createResponse(props, context) {
|
|
750
|
+
export function createResponse(props, context, isStatic = true) {
|
|
751
751
|
var _a, _b, _c, _d;
|
|
752
752
|
const { data, meta, error } = props;
|
|
753
753
|
const pageUrl = (_c = (_b = (_a = data === null || data === void 0 ? void 0 : data.get) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.target) === null || _c === void 0 ? void 0 : _c.pageUrl;
|
|
@@ -774,11 +774,14 @@ export function createResponse(props, context) {
|
|
|
774
774
|
const catchAllInNextProdMode = (meta === null || meta === void 0 ? void 0 : meta.renderMode) === RENDER_MODE.NEXT && !IS_DEV_MODE && (meta === null || meta === void 0 ? void 0 : meta.catchAll);
|
|
775
775
|
const notFound = (error && error.code === '404') || ((_d = context.res) === null || _d === void 0 ? void 0 : _d.statusCode) === 404 || canNotRender || catchAllInNextProdMode || undefined;
|
|
776
776
|
// console.debug('Returning view ' + (notFound ? '(not found)' : ''));
|
|
777
|
-
|
|
777
|
+
const result = {
|
|
778
778
|
notFound,
|
|
779
779
|
props,
|
|
780
|
-
revalidate: 3600, // In seconds, meaning every hour
|
|
781
780
|
};
|
|
781
|
+
if (isStatic) {
|
|
782
|
+
result.revalidate = 3600; // In seconds, meaning every hour
|
|
783
|
+
}
|
|
784
|
+
return result;
|
|
782
785
|
}
|
|
783
786
|
function populateEnonicHeaders(context) {
|
|
784
787
|
const pd = context.previewData;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@enonic/nextjs-adapter",
|
|
3
|
-
"version": "2.0.0
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"publishConfig": {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"lint:fix": "eslint --fix server && eslint --fix src"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"html-react-parser": "^4.2.
|
|
16
|
+
"html-react-parser": "^4.2.2",
|
|
17
17
|
"lru-cache": "^10.0.1",
|
|
18
18
|
"next": "13.4.19",
|
|
19
19
|
"react": "18.2.0",
|
|
@@ -22,13 +22,13 @@
|
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@enonic/eslint-config": "^1.1.0",
|
|
25
|
-
"@types/node": "^20.
|
|
26
|
-
"@types/react": "18.2.
|
|
25
|
+
"@types/node": "^20.6.0",
|
|
26
|
+
"@types/react": "18.2.21",
|
|
27
27
|
"@types/react-dom": "18.2.7",
|
|
28
28
|
"@typescript-eslint/eslint-plugin": "^5.61.0",
|
|
29
29
|
"@typescript-eslint/parser": "^5.62.0",
|
|
30
|
-
"eslint": "^8.
|
|
30
|
+
"eslint": "^8.49.0",
|
|
31
31
|
"eslint-plugin-react": "^7.33.2",
|
|
32
|
-
"typescript": "^5.
|
|
32
|
+
"typescript": "^5.2.2"
|
|
33
33
|
}
|
|
34
34
|
}
|
package/utils.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ export declare const DEFAULT_LOCALE_HEADER = "default-locale";
|
|
|
37
37
|
* - media
|
|
38
38
|
* - paths with '/_' in them
|
|
39
39
|
*/
|
|
40
|
-
export declare const GET_STATIC_PATHS_QUERY = "query ($count: Int) {\n guillotine {\n queryDsl(\n first: $count,\n sort: {\n field: \"modifiedTime\",\n direction: DESC \n }\n query: {boolean: {mustNot: [\n {in: {field: \"type\", stringValues: [\"base:folder\", \"base:shortcut\"]}}\n {like: {field: \"type\", value:
|
|
40
|
+
export declare const GET_STATIC_PATHS_QUERY = "query ($count: Int) {\n guillotine {\n queryDsl(\n first: $count,\n sort: {\n field: \"modifiedTime\",\n direction: DESC \n }\n query: {boolean: {mustNot: [\n {in: {field: \"type\", stringValues: [\"base:folder\", \"base:shortcut\"]}}\n {like: {field: \"type\", value: \"media:*\"}}\n {like: {field: \"_path\", value: \"*/_*\"}}\n ]}}\n ) {\n _name\n _path\n site {_name}\n }\n }\n}";
|
|
41
41
|
export declare enum XP_REQUEST_TYPE {
|
|
42
42
|
COMPONENT = "component",
|
|
43
43
|
TYPE = "type",
|
package/utils.js
CHANGED
|
@@ -50,8 +50,8 @@ export const GET_STATIC_PATHS_QUERY = `query ($count: Int) {
|
|
|
50
50
|
}
|
|
51
51
|
query: {boolean: {mustNot: [
|
|
52
52
|
{in: {field: "type", stringValues: ["base:folder", "base:shortcut"]}}
|
|
53
|
-
{like: {field: "type", value:
|
|
54
|
-
{like: {field: "_path", value:
|
|
53
|
+
{like: {field: "type", value: "media:*"}}
|
|
54
|
+
{like: {field: "_path", value: "*/_*"}}
|
|
55
55
|
]}}
|
|
56
56
|
) {
|
|
57
57
|
_name
|