Skip to content

Commit

Permalink
[SXA][Next.js] Add condition DISABLE_SSG_FETCH for 404/500 pages to e…
Browse files Browse the repository at this point in the history
…nable full ISR (Incremental Static Regeneration) flow
  • Loading branch information
illiakovalenko committed May 26, 2023
1 parent 625591a commit 66a032a
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 4 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,24 @@ Our versioning strategy is as follows:

## Unreleased

## 21.1.6

### 🐛 Bug Fixes

`[templates/nextjs-sxa]` Add condition DISABLE_SSG_FETCH for 404/500 pages to enable full ISR (Incremental Static Regeneration) flow ([#1496](https://github.com/Sitecore/jss/pull/1496))

## 21.1.5

### 🐛 Bug Fixes

* `[create-sitecore-jss]` Change ^ to ~ for versioning in templates and use exact versions for sitecore-jss monorepo dependencies.

## 21.1.4

### 🐛 Bug Fixes

* `[create-sitecore-jss]` Change ^ to ~ for versioning in templates.

## 21.1.3

### 🐛 Bug Fixes
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import config from 'temp/config';
import { GraphQLErrorPagesService, SitecoreContext } from '@sitecore-jss/sitecore-jss-nextjs';
import {
GraphQLErrorPagesService,
SitecoreContext,
ErrorPages,
} from '@sitecore-jss/sitecore-jss-nextjs';
import { SitecorePageProps } from 'lib/page-props';
import NotFound from 'src/NotFound';
import { componentFactory } from 'temp/componentFactory';
Expand Down Expand Up @@ -27,8 +31,16 @@ export const getStaticProps: GetStaticProps = async (context) => {
siteName: site.name,
language: context.locale || config.defaultLanguage,
});
let resultErrorPages: ErrorPages | null = null;

const resultErrorPages = await errorPagesService.fetchErrorPages();
if (!process.env.DISABLE_SSG_FETCH) {
try {
resultErrorPages = await errorPagesService.fetchErrorPages();
} catch (error) {
console.log('Error occurred while fetching error pages');
console.log(error);
}
}

return {
props: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import Head from 'next/head';
import { GraphQLErrorPagesService, SitecoreContext } from '@sitecore-jss/sitecore-jss-nextjs';
import {
GraphQLErrorPagesService,
SitecoreContext,
ErrorPages,
} from '@sitecore-jss/sitecore-jss-nextjs';
import { SitecorePageProps } from 'lib/page-props';
import Layout from 'src/Layout';
import { componentFactory } from 'temp/componentFactory';
Expand Down Expand Up @@ -43,8 +47,16 @@ export const getStaticProps: GetStaticProps = async (context) => {
siteName: site.name,
language: context.locale || context.defaultLocale || config.defaultLanguage,
});
let resultErrorPages: ErrorPages | null = null;

const resultErrorPages = await errorPagesService.fetchErrorPages();
if (!process.env.DISABLE_SSG_FETCH) {
try {
resultErrorPages = await errorPagesService.fetchErrorPages();
} catch (error) {
console.log('Error occurred while fetching error pages');
console.log(error);
}
}

return {
props: {
Expand Down

0 comments on commit 66a032a

Please sign in to comment.