diff --git a/examples/nextjs/package-lock.json b/examples/nextjs/package-lock.json index 6b2d41b01204..b73338b95df4 100644 --- a/examples/nextjs/package-lock.json +++ b/examples/nextjs/package-lock.json @@ -8,9 +8,9 @@ "name": "nextjs-dotcms-ema", "version": "0.1.0", "dependencies": { - "@dotcms/client": "0.0.1-alpha.31", - "@dotcms/experiments": "0.0.1-alpha.31", - "@dotcms/react": "0.0.1-alpha.31", + "@dotcms/client": "0.0.1-alpha.35", + "@dotcms/experiments": "0.0.1-alpha.35", + "@dotcms/react": "0.0.1-alpha.35", "next": "14.1.1", "react": "^18", "react-dom": "^18" @@ -49,29 +49,33 @@ } }, "node_modules/@dotcms/client": { - "version": "0.0.1-alpha.31", - "resolved": "https://registry.npmjs.org/@dotcms/client/-/client-0.0.1-alpha.31.tgz", - "integrity": "sha512-FD9c8j20nTNY+ATlQHuESjBg+5DkyX0idTBCLMOadZJmNftIf5niDHd1y6VMS+p0xN3RyKeBxYIeUsH7YTOU5g==" + "version": "0.0.1-alpha.35", + "resolved": "https://registry.npmjs.org/@dotcms/client/-/client-0.0.1-alpha.35.tgz", + "integrity": "sha512-1y5ShVeWGDWtKHSHdjo8+b8z6eKyyc1ELKsM/oB2BgWQ920T7Nqld7wkHrQHuc5H9zUW4wpUHw6nGoT595Be4Q==", + "license": "MIT" }, "node_modules/@dotcms/experiments": { - "version": "0.0.1-alpha.31", - "resolved": "https://registry.npmjs.org/@dotcms/experiments/-/experiments-0.0.1-alpha.31.tgz", - "integrity": "sha512-dKsbHTw7qsmBjJ67z8oZV6SpfKPeB9XbiC7rfm1hyh30BnBwpBrKOSuzSLXLSpQVONj1uteKqGHar/nvGIAIOA==", + "version": "0.0.1-alpha.35", + "resolved": "https://registry.npmjs.org/@dotcms/experiments/-/experiments-0.0.1-alpha.35.tgz", + "integrity": "sha512-7jp4tSW9Oy9JV5Fy4viElBDwQhfOucymeWBkr37DDhi9QjeH5/2HsyA7mCnUfKU0V3DhSfjWSWcZjaRZ3Oi6Zw==", + "license": "MIT", "dependencies": { "@jitsu/sdk-js": "^3.1.5" }, "peerDependencies": { - "@dotcms/client": "0.0.1-alpha.31", + "@dotcms/client": "0.0.1-alpha.35", "react": ">=18", "react-dom": ">=18" } }, "node_modules/@dotcms/react": { - "version": "0.0.1-alpha.31", - "resolved": "https://registry.npmjs.org/@dotcms/react/-/react-0.0.1-alpha.31.tgz", - "integrity": "sha512-NDH9TeasIImm+Jc5j7TNJFaeix7qie+pTXFbBGZdmSRr2gZyBuVTeujjVVtLLy4DNj/B8J38pqFlA0urlRTQsA==", + "version": "0.0.1-alpha.35", + "resolved": "https://registry.npmjs.org/@dotcms/react/-/react-0.0.1-alpha.35.tgz", + "integrity": "sha512-fEt7DN63Ujv1czMTuvXNCWzlBNGGJo/m0HHB9vtLM/6IFz5Fc6iY3AjcYc6MAgBc3AlnfL4aeVJh0+yTtArXGA==", + "license": "MIT", "peerDependencies": { - "@dotcms/client": "0.0.1-alpha.31", + "@dotcms/client": "0.0.1-alpha.35", + "@tinymce/tinymce-react": "^5.1.1", "react": ">=18", "react-dom": ">=18" } @@ -501,6 +505,21 @@ "node": ">=4" } }, + "node_modules/@tinymce/tinymce-react": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/@tinymce/tinymce-react/-/tinymce-react-5.1.1.tgz", + "integrity": "sha512-DQ0wpvnf/9z8RsOEAmrWZ1DN1PKqcQHfU+DpM3llLze7FHmxVtzuN8O+FYh0oAAF4stzAXwiCIVacfqjMwRieQ==", + "license": "MIT", + "peer": true, + "dependencies": { + "prop-types": "^15.6.2", + "tinymce": "^7.0.0 || ^6.0.0 || ^5.5.1" + }, + "peerDependencies": { + "react": "^18.0.0 || ^17.0.1 || ^16.7.0", + "react-dom": "^18.0.0 || ^17.0.1 || ^16.7.0" + } + }, "node_modules/@types/json5": { "version": "0.0.29", "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz", @@ -3315,7 +3334,6 @@ "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", - "dev": true, "engines": { "node": ">=0.10.0" } @@ -3786,7 +3804,6 @@ "version": "15.8.1", "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz", "integrity": "sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==", - "dev": true, "dependencies": { "loose-envify": "^1.4.0", "object-assign": "^4.1.1", @@ -3848,8 +3865,7 @@ "node_modules/react-is": { "version": "16.13.1", "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", - "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==", - "dev": true + "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==" }, "node_modules/read-cache": { "version": "1.0.0", @@ -4539,6 +4555,13 @@ "node": ">=0.8" } }, + "node_modules/tinymce": { + "version": "7.3.0", + "resolved": "https://registry.npmjs.org/tinymce/-/tinymce-7.3.0.tgz", + "integrity": "sha512-Ls4PgYlpk73XAxBSBqbVmSl8Mb3DuNfgF01GZ0lY6/MOEVRl3IL+VxC1Oe6165e8WqbqVsxO3Qj/PmoYNvQKGQ==", + "license": "GPL-2.0-or-later", + "peer": true + }, "node_modules/to-regex-range": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", diff --git a/examples/nextjs/src/app/[[...slug]]/page.js b/examples/nextjs/src/app/[[...slug]]/page.js index b8b45b9ba742..a62110805d0f 100644 --- a/examples/nextjs/src/app/[[...slug]]/page.js +++ b/examples/nextjs/src/app/[[...slug]]/page.js @@ -42,7 +42,10 @@ export default async function Home({ searchParams, params }) { path, params: searchParams, }); - const pageAsset = await client.page.get(pageRequestParams); + const pageAsset = await client.page.get({ + ...pageRequestParams, + depth: 3, + }); const nav = await client.nav.get({ path: "/", depth: 2, diff --git a/examples/nextjs/src/components/content-types/calendarEvent.js b/examples/nextjs/src/components/content-types/calendarEvent.js index 9a96c136f5b9..becd257b00e3 100644 --- a/examples/nextjs/src/components/content-types/calendarEvent.js +++ b/examples/nextjs/src/components/content-types/calendarEvent.js @@ -2,14 +2,21 @@ import Image from "next/image"; import Link from "next/link"; function extractLocationsAndActivities(contentlet) { - return contentlet.reduce( - (acc, { activities, ...location }) => { + const initialValue = { + locations: [], + activities: [], + }; + + return ( + contentlet?.reduce((acc, { activities, ...location }) => { + // This is a relationship between Contentlets + // Event -> Location -> Activities + // Depth 3 acc.activities = acc.activities.concat(activities); acc.locations.push(location); return acc; - }, - { locations: [], activities: [] } + }, initialValue) ?? initialValue ); } @@ -31,36 +38,42 @@ function CalendarEvent({ image, title, urlMap, description, location }) {

{title}

-
- - Locations: - -   - {locations.map(({ title, url }, index) => { - return ( - - - {title} - - - ); - })} -
-
- - Activities: - -   - {activities.slice(0, 3).map(({ title, urlMap }, index) => { - return ( - - - {title} - - - ); - })} -
+ {!!locations.length && !!locations[0]?.title && ( +
+ + Locations: + +   + {locations.map(({ title, url }, index) => { + return ( + + + {title} + + + ); + })} +
+ )} + {!!activities.length && !!activities[0]?.title && ( +
+ + Activities: + +   + {activities + .slice(0, 3) + .map(({ title, urlMap }, index) => { + return ( + + + {title} + + + ); + })} +
+ )}