create-sitecore-jss 21.1.1 → 21.1.2

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.
@@ -129,14 +129,16 @@
129
129
  "yaml-lint": "^1.2.4"
130
130
  },
131
131
  "//": [
132
- "overrides (for npm) and resolutions (for yarn) used to work around the bug in critters that affect bootstrap: https://github.com/GoogleChromeLabs/critters/issues/103",
133
- "both sections can be removed once critters and css-select versions are updated in build-angular"
132
+ "both sections can be removed once critters and css-select versions are updated in build-angular",
133
+ "for webpack, we use lower version to fix the angular/webpack bug: https://github.com/webpack/webpack/issues/16981 that prevents project from building",
134
+ "remove webpack override when upgrading Angular to next major version"
134
135
  ],
135
136
  "overrides": {
136
137
  "@angular-devkit/build-angular": {
137
138
  "critters": {
138
139
  "css-select": "4.2.1"
139
- }
140
+ },
141
+ "webpack": "5.78.0"
140
142
  }
141
143
  },
142
144
  "resolutions": {
@@ -1,4 +1,3 @@
1
- import { Redirect } from 'next';
2
1
  import {
3
2
  DictionaryPhrases,
4
3
  ComponentPropsCollection,
@@ -16,5 +15,4 @@ export type SitecorePageProps = {
16
15
  componentProps: ComponentPropsCollection;
17
16
  notFound: boolean;
18
17
  layoutData: LayoutServiceData;
19
- redirect?: Redirect;
20
18
  };
@@ -103,13 +103,6 @@ export const getServerSideProps: GetServerSideProps = async (context) => {
103
103
  <% } -%>
104
104
  const props = await sitecorePagePropsFactory.create(context);
105
105
 
106
- // Check if we have a redirect (e.g. custom error page)
107
- if (props.redirect) {
108
- return {
109
- redirect: props.redirect,
110
- };
111
- }
112
-
113
106
  return {
114
107
  props,
115
108
  <% if (prerender === 'SSG') { -%>
@@ -0,0 +1,41 @@
1
+ import config from 'temp/config';
2
+ import { GraphQLErrorPagesService, SitecoreContext } from '@sitecore-jss/sitecore-jss-nextjs';
3
+ import { SitecorePageProps } from 'lib/page-props';
4
+ import NotFound from 'src/NotFound';
5
+ import { componentFactory } from 'temp/componentFactory';
6
+ import Layout from 'src/Layout';
7
+ import { GetStaticProps } from 'next';
8
+ import { siteResolver } from 'lib/site-resolver';
9
+
10
+ const Custom404 = (props: SitecorePageProps): JSX.Element => {
11
+ if (!(props && props.layoutData)) {
12
+ return <NotFound />;
13
+ }
14
+
15
+ return (
16
+ <SitecoreContext componentFactory={componentFactory} layoutData={props.layoutData}>
17
+ <Layout layoutData={props.layoutData} headLinks={props.headLinks} />
18
+ </SitecoreContext>
19
+ );
20
+ };
21
+
22
+ export const getStaticProps: GetStaticProps = async (context) => {
23
+ const site = siteResolver.getByName(config.jssAppName);
24
+ const errorPagesService = new GraphQLErrorPagesService({
25
+ endpoint: config.graphQLEndpoint,
26
+ apiKey: config.sitecoreApiKey,
27
+ siteName: site.name,
28
+ language: context.locale || config.defaultLanguage,
29
+ });
30
+
31
+ const resultErrorPages = await errorPagesService.fetchErrorPages();
32
+
33
+ return {
34
+ props: {
35
+ headLinks: [],
36
+ layoutData: resultErrorPages?.notFoundPage?.rendered || null,
37
+ },
38
+ };
39
+ };
40
+
41
+ export default Custom404;
@@ -0,0 +1,57 @@
1
+ import Head from 'next/head';
2
+ import { GraphQLErrorPagesService, SitecoreContext } from '@sitecore-jss/sitecore-jss-nextjs';
3
+ import { SitecorePageProps } from 'lib/page-props';
4
+ import Layout from 'src/Layout';
5
+ import { componentFactory } from 'temp/componentFactory';
6
+ import { GetStaticProps } from 'next';
7
+ import config from 'temp/config';
8
+ import { siteResolver } from 'lib/site-resolver';
9
+
10
+ /**
11
+ * Rendered in case if we have 500 error
12
+ */
13
+ const ServerError = (): JSX.Element => (
14
+ <>
15
+ <Head>
16
+ <title>500: Server Error</title>
17
+ </Head>
18
+ <div style={{ padding: 10 }}>
19
+ <h1>500 Internal Server Error</h1>
20
+ <p>There is a problem with the resource you are looking for, and it cannot be displayed.</p>
21
+ <a href="/">Go to the Home page</a>
22
+ </div>
23
+ </>
24
+ );
25
+
26
+ const Custom500 = (props: SitecorePageProps): JSX.Element => {
27
+ if (!(props && props.layoutData)) {
28
+ return <ServerError />;
29
+ }
30
+
31
+ return (
32
+ <SitecoreContext componentFactory={componentFactory} layoutData={props.layoutData}>
33
+ <Layout layoutData={props.layoutData} headLinks={props.headLinks} />
34
+ </SitecoreContext>
35
+ );
36
+ };
37
+
38
+ export const getStaticProps: GetStaticProps = async (context) => {
39
+ const site = siteResolver.getByName(config.jssAppName);
40
+ const errorPagesService = new GraphQLErrorPagesService({
41
+ endpoint: config.graphQLEndpoint,
42
+ apiKey: config.sitecoreApiKey,
43
+ siteName: site.name,
44
+ language: context.locale || context.defaultLocale || config.defaultLanguage,
45
+ });
46
+
47
+ const resultErrorPages = await errorPagesService.fetchErrorPages();
48
+
49
+ return {
50
+ props: {
51
+ headLinks: [],
52
+ layoutData: resultErrorPages?.serverErrorPage?.rendered || null,
53
+ },
54
+ };
55
+ };
56
+
57
+ export default Custom500;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-sitecore-jss",
3
- "version": "21.1.1",
3
+ "version": "21.1.2",
4
4
  "description": "Sitecore JSS initializer",
5
5
  "bin": "./dist/index.js",
6
6
  "scripts": {
@@ -64,5 +64,5 @@
64
64
  "ts-node": "^10.9.1",
65
65
  "typescript": "~4.9.5"
66
66
  },
67
- "gitHead": "ae9d7fc994fa11061b5a164ff6a86b3ccf845a4c"
67
+ "gitHead": "12d90ddedd13d277fe824fa502de1d2c3e3ef489"
68
68
  }
@@ -1,53 +0,0 @@
1
- import { GetServerSidePropsContext, GetStaticPropsContext } from 'next';
2
- import { SitecorePageProps } from 'lib/page-props';
3
- import { Plugin } from 'lib/page-props-factory';
4
- import { GraphQLErrorPagesService } from '@sitecore-jss/sitecore-jss-nextjs';
5
- import { isServerSidePropsContext } from '..';
6
- import config from 'temp/config';
7
-
8
- class ErrorPagesPlugin implements Plugin {
9
- order = 3;
10
-
11
- async exec(props: SitecorePageProps, context: GetServerSidePropsContext | GetStaticPropsContext) {
12
- if (context.preview) return props;
13
-
14
- const errorPagesService = new GraphQLErrorPagesService({
15
- endpoint: config.graphQLEndpoint,
16
- apiKey: config.sitecoreApiKey,
17
- siteName: props.site.name,
18
- language: props.locale,
19
- });
20
-
21
- if (props.notFound) {
22
- const resultErrorPages = await errorPagesService.fetchErrorPages();
23
-
24
- if (resultErrorPages?.notFoundPagePath) {
25
- return {
26
- ...props,
27
- redirect: {
28
- destination: resultErrorPages.notFoundPagePath,
29
- permanent: false,
30
- }
31
- }
32
- }
33
- }
34
-
35
- if (isServerSidePropsContext(context) && context.res.statusCode >= 500 && context.res.statusCode <= 511) {
36
- const resultErrorPages = await errorPagesService.fetchErrorPages();
37
-
38
- if (resultErrorPages?.serverErrorPagePath) {
39
- return {
40
- ...props,
41
- redirect: {
42
- destination: resultErrorPages.serverErrorPagePath,
43
- permanent: false,
44
- }
45
- }
46
- }
47
- }
48
-
49
- return props;
50
- }
51
- }
52
-
53
- export const errorPagesPlugin = new ErrorPagesPlugin();