create-content-sdk-app 2.0.0-canary.13 → 2.0.0-canary.15
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.
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
import Link from 'next/link';
|
|
2
|
-
import { headers } from 'next/headers';
|
|
3
2
|
import { Suspense } from 'react';
|
|
4
|
-
import { ErrorPage } from '@sitecore-content-sdk/nextjs';
|
|
5
|
-
import { parseRewriteHeader } from '@sitecore-content-sdk/nextjs/utils';
|
|
3
|
+
import { ErrorPage, getCachedPageParams } from '@sitecore-content-sdk/nextjs';
|
|
6
4
|
import client from 'lib/sitecore-client';
|
|
7
5
|
import scConfig from 'sitecore.config';
|
|
8
6
|
import Layout from 'src/Layout';
|
|
9
7
|
import Providers from 'src/Providers';
|
|
10
8
|
import { NextIntlClientProvider } from 'next-intl';
|
|
11
9
|
|
|
12
|
-
// Part of not-found component that handles dynamic data
|
|
10
|
+
// Part of not-found component that handles dynamic data like error page fetching.
|
|
13
11
|
// This component is wrapped in Suspense to enable Next.js 16 Partial Prerendering (PPR),
|
|
14
12
|
// which allows streaming dynamic content while keeping static parts prerendered.
|
|
15
13
|
// This pattern also works seamlessly when Cache Components is enabled.
|
|
16
|
-
async function
|
|
17
|
-
const
|
|
18
|
-
const { site, locale } = parseRewriteHeader(headersList);
|
|
14
|
+
async function NotFoundContent() {
|
|
15
|
+
const { site, locale } = getCachedPageParams();
|
|
19
16
|
|
|
20
17
|
const page = await client.getErrorPage(ErrorPage.NotFound, {
|
|
21
18
|
site: site || scConfig.defaultSite,
|
|
@@ -53,7 +50,7 @@ export default function NotFound() {
|
|
|
53
50
|
</div>
|
|
54
51
|
}
|
|
55
52
|
>
|
|
56
|
-
<
|
|
53
|
+
<NotFoundContent />
|
|
57
54
|
</Suspense>
|
|
58
55
|
);
|
|
59
56
|
}
|
|
@@ -19,11 +19,11 @@ type PageProps = {
|
|
|
19
19
|
searchParams: Promise<{ [key: string]: string | string[] | undefined }>;
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
// Part of page component that handles
|
|
22
|
+
// Part of page component that handles data, like the `draftMode()` call and data fetching.
|
|
23
23
|
// This component is wrapped in Suspense to enable Next.js 16 Partial Prerendering (PPR),
|
|
24
|
-
// which allows streaming
|
|
24
|
+
// which allows streaming content while keeping static parts prerendered.
|
|
25
25
|
// This pattern also works seamlessly when Cache Components is enabled.
|
|
26
|
-
async function
|
|
26
|
+
async function PageContent({ site, locale, path, searchParams }: { site: string; locale: string; path?: string[]; searchParams: Promise<{ [key: string]: string | string[] | undefined }> }) {
|
|
27
27
|
const draft = await draftMode();
|
|
28
28
|
|
|
29
29
|
// Fetch the page data from Sitecore
|
|
@@ -63,7 +63,7 @@ export default async function Page({ params, searchParams }: PageProps) {
|
|
|
63
63
|
// PPR allows streaming dynamic content while keeping static parts prerendered for better performance.
|
|
64
64
|
return (
|
|
65
65
|
<Suspense fallback={<div>Loading...</div>}>
|
|
66
|
-
<
|
|
66
|
+
<PageContent site={site} locale={locale} path={path} searchParams={searchParams} />
|
|
67
67
|
</Suspense>
|
|
68
68
|
);
|
|
69
69
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { setCachedPageParams } from '@sitecore-content-sdk/nextjs';
|
|
2
|
+
|
|
3
|
+
export default async function SiteLayout({
|
|
4
|
+
children,
|
|
5
|
+
params,
|
|
6
|
+
}: {
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
params: Promise<{ site: string; locale: string }>;
|
|
9
|
+
}) {
|
|
10
|
+
const { site, locale } = await params;
|
|
11
|
+
|
|
12
|
+
// Update the cached page info with the current site and locale values.
|
|
13
|
+
// This ensures the notFound page can access the correct site and locale information when rendered
|
|
14
|
+
// without opting out of SSG by using functions like `headers()`.
|
|
15
|
+
setCachedPageParams({ locale, site });
|
|
16
|
+
|
|
17
|
+
return <>{children}</>;
|
|
18
|
+
}
|
|
19
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-content-sdk-app",
|
|
3
|
-
"version": "2.0.0-canary.
|
|
3
|
+
"version": "2.0.0-canary.15",
|
|
4
4
|
"description": "Sitecore Content SDK initializer",
|
|
5
5
|
"bin": "./dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"ts-node": "^10.9.2",
|
|
71
71
|
"typescript": "~5.8.3"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "1159415b0cb719120735fa7d33e0aaac46a65cdb"
|
|
74
74
|
}
|