create-sitecore-jss 22.6.0-canary.17 → 22.6.0-canary.19

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.
@@ -0,0 +1,24 @@
1
+ import { ComponentBuilderPlugin, ComponentBuilderPluginConfig } from '..';
2
+
3
+ /**
4
+ * Provides Form component configuration
5
+ */
6
+ class FormPlugin implements ComponentBuilderPlugin {
7
+ order = 1;
8
+
9
+ exec(config: ComponentBuilderPluginConfig) {
10
+ config.packages.push({
11
+ name: '@sitecore-jss/sitecore-jss-nextjs',
12
+ components: [
13
+ {
14
+ componentName: 'Form',
15
+ moduleName: 'Form',
16
+ },
17
+ ],
18
+ });
19
+
20
+ return config;
21
+ }
22
+ }
23
+
24
+ export const formPlugin = new FormPlugin();
@@ -5,10 +5,6 @@ import * as FEAAS from '@sitecore-feaas/clientside/react';
5
5
  * to reduce javascript bundle size.
6
6
  */
7
7
 
8
- // SitecoreForm component displays forms created in XM Forms as individual components to be embedded into Pages.
9
- // Sitecore Forms for Sitecore XP are still available separately via @sitecore-jss-forms package
10
- import '@sitecore/components/form';
11
-
12
8
  /**
13
9
  * End of built-in JSS imports
14
10
  * You can import your own client component below
@@ -14,6 +14,10 @@ const monorepoPlugin = (nextConfig = {}) => {
14
14
  './node_modules/@sitecore-feaas/clientside/dist/browser/react.esm.js'
15
15
  );
16
16
 
17
+ config.resolve.alias['@sitecore-cloudsdk/events'] = path.resolve(
18
+ CWD, './node_modules/@sitecore-cloudsdk/events'
19
+ );
20
+
17
21
  // Overload the Webpack config if it was already overloaded
18
22
  if (typeof nextConfig.webpack === 'function') {
19
23
  return nextConfig.webpack(config, options);
@@ -0,0 +1,112 @@
1
+ import { useEffect } from 'react';
2
+ <% if (prerender === 'SSG') { -%>
3
+ import { GetStaticPaths, GetStaticProps } from 'next';
4
+ <% } else if (prerender === 'SSR') { -%>
5
+ import { GetServerSideProps } from 'next';
6
+ <% } -%>
7
+ import NotFound from 'src/NotFound';
8
+ import Layout from 'src/Layout';
9
+ import {
10
+ SitecoreContext,
11
+ ComponentPropsContext,
12
+ <% if (prerender === 'SSG') { -%>
13
+ StaticPath,
14
+ <% } -%>
15
+ } from '@sitecore-jss/sitecore-jss-nextjs';
16
+ import { handleEditorFastRefresh } from '@sitecore-jss/sitecore-jss-nextjs/utils';
17
+ import { SitecorePageProps } from 'lib/page-props';
18
+ import { sitecorePagePropsFactory } from 'lib/page-props-factory';
19
+ import { componentBuilder } from 'temp/componentBuilder';
20
+ import config from 'temp/config';
21
+ <% if (prerender === 'SSG') { -%>
22
+ import { sitemapFetcher } from 'lib/sitemap-fetcher';
23
+
24
+ <% } -%>
25
+
26
+ const SitecorePage = ({ notFound, componentProps, layoutData, headLinks }: SitecorePageProps): JSX.Element => {
27
+ useEffect(() => {
28
+ // Since Sitecore editors do not support Fast Refresh, need to refresh editor chromes after Fast Refresh finished
29
+ handleEditorFastRefresh();
30
+ }, []);
31
+
32
+ if (notFound || !layoutData.sitecore.route) {
33
+ // Shouldn't hit this (as long as 'notFound' is being returned below), but just to be safe
34
+ return <NotFound />;
35
+ }
36
+
37
+ const isEditing = layoutData.sitecore.context.pageEditing;
38
+
39
+ return (
40
+ <ComponentPropsContext value={componentProps}>
41
+ <SitecoreContext
42
+ componentFactory={componentBuilder.getComponentFactory({ isEditing })}
43
+ layoutData={layoutData}
44
+ api={{
45
+ edge: {
46
+ contextId: config.sitecoreEdgeContextId,
47
+ edgeUrl: config.sitecoreEdgeUrl,
48
+ },
49
+ }}
50
+ >
51
+ <Layout layoutData={layoutData} headLinks={headLinks} />
52
+ </SitecoreContext>
53
+ </ComponentPropsContext>
54
+ );
55
+ };
56
+
57
+ <% if (prerender === 'SSG') { -%>
58
+ // This function gets called at build and export time to determine
59
+ // pages for SSG ("paths", as tokenized array).
60
+ export const getStaticPaths: GetStaticPaths = async (context) => {
61
+ // Fallback, along with revalidate in getStaticProps (below),
62
+ // enables Incremental Static Regeneration. This allows us to
63
+ // leave certain (or all) paths empty if desired and static pages
64
+ // will be generated on request (development mode in this example).
65
+ // Alternatively, the entire sitemap could be pre-rendered
66
+ // ahead of time (non-development mode in this example).
67
+ // See https://nextjs.org/docs/basic-features/data-fetching/incremental-static-regeneration
68
+
69
+ let paths: StaticPath[] = [];
70
+ let fallback: boolean | 'blocking' = 'blocking';
71
+
72
+ if (process.env.NODE_ENV !== 'development' && process.env.DISABLE_SSG_FETCH?.toLowerCase() !== 'true') {
73
+ try {
74
+ // Note: Next.js runs export in production mode
75
+ paths = await sitemapFetcher.fetch(context);
76
+ } catch (error) {
77
+ console.log('Error occurred while fetching static paths');
78
+ console.log(error);
79
+ }
80
+
81
+ fallback = process.env.EXPORT_MODE ? false : fallback;
82
+ }
83
+
84
+ return {
85
+ paths,
86
+ fallback,
87
+ };
88
+ };
89
+
90
+ // This function gets called at build time on server-side.
91
+ // It may be called again, on a serverless function, if
92
+ // revalidation (or fallback) is enabled and a new request comes in.
93
+ export const getStaticProps: GetStaticProps = async (context) => {
94
+ <% } else if (prerender === 'SSR') { -%>
95
+ // This function gets called at request time on server-side.
96
+ export const getServerSideProps: GetServerSideProps = async (context) => {
97
+ <% } -%>
98
+ const props = await sitecorePagePropsFactory.create(context);
99
+
100
+ return {
101
+ props,
102
+ <% if (prerender === 'SSG') { -%>
103
+ // Next.js will attempt to re-generate the page:
104
+ // - When a request comes in
105
+ // - At most once every 5 seconds
106
+ revalidate: 5, // In seconds
107
+ <% } -%>
108
+ notFound: props.notFound, // Returns custom 404 page with a status code of 404 when true
109
+ };
110
+ };
111
+
112
+ export default SitecorePage;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-sitecore-jss",
3
- "version": "22.6.0-canary.17",
3
+ "version": "22.6.0-canary.19",
4
4
  "description": "Sitecore JSS initializer",
5
5
  "bin": "./dist/index.js",
6
6
  "scripts": {
@@ -65,5 +65,5 @@
65
65
  "ts-node": "^10.9.1",
66
66
  "typescript": "~5.6.3"
67
67
  },
68
- "gitHead": "b670d25f990eb062994942b261eed22a83ff8bd4"
68
+ "gitHead": "1377828d4b015edee249bd41843e3ad7c9ea127c"
69
69
  }