Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multisite SSG should always include site prefix #1339

Merged
merged 6 commits into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ Our versioning strategy is as follows:
* `import { editingDataService } from '@sitecore-jss/sitecore-jss-nextjs/editing';`
* `import { EditingRenderMiddleware } from '@sitecore-jss/sitecore-jss-nextjs/editing';`

* `[sitecore-jss-nextjs]` GraphqlSitemapService's constructor accepts a sites array by default, instead of siteName. fetchExportSitemap and fetchSSGSitemap methods will now return paths with site prefix applies by default. Provide a siteName parameter into the methods to get paths for a single site without prefix.
ambrauer marked this conversation as resolved.
Show resolved Hide resolved
art-alexeyenko marked this conversation as resolved.
Show resolved Hide resolved

* `[sitecore-jss-angular][templates/angular]` jss-angular package and sample has been updated to version 14. This means several changes:
* JSS Angular sample is now using Ivy
* IE11 no longer supported by JSS Angular
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import {
MultisiteGraphQLSitemapService,
StaticPath,
constants,
SiteInfo,
} from '@sitecore-jss/sitecore-jss-nextjs';
import config from 'temp/config';
import { SitemapFetcherPlugin } from '..';
import { GetStaticPathsContext } from 'next';
import { siteResolver } from 'lib/site-resolver';

class GraphqlSitemapServicePlugin implements SitemapFetcherPlugin {
_graphqlSitemapService: MultisiteGraphQLSitemapService;

constructor() {
this._graphqlSitemapService = new MultisiteGraphQLSitemapService({
endpoint: config.graphQLEndpoint,
apiKey: config.sitecoreApiKey,
sites: [...new Set(siteResolver.sites.map((site: SiteInfo) => site.name))],
});
}

async exec(context?: GetStaticPathsContext): Promise<StaticPath[]> {
if (process.env.EXPORT_MODE) {
if (process.env.JSS_MODE === constants.JSS_MODE.DISCONNECTED) {
return [];
}
return process.env.EXPORT_MODE
? this._graphqlSitemapService.fetchExportSitemap(config.defaultLanguage)
: this._graphqlSitemapService.fetchSSGSitemap(context?.locales || []);
}
return this._graphqlSitemapService.fetchSSGSitemap(context?.locales || []);
ambrauer marked this conversation as resolved.
Show resolved Hide resolved
}
}

export const graphqlSitemapServicePlugin = new GraphqlSitemapServicePlugin();
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
GraphQLSitemapService,
StaticPath,
constants,
SiteInfo,
} from '@sitecore-jss/sitecore-jss-nextjs';
import config from 'temp/config';
import { SitemapFetcherPlugin } from '..';
import { GetStaticPathsContext } from 'next';
import { siteResolver } from 'lib/site-resolver';

class GraphqlSitemapServicePlugin implements SitemapFetcherPlugin {
_graphqlSitemapService: GraphQLSitemapService;
Expand All @@ -16,16 +14,18 @@ class GraphqlSitemapServicePlugin implements SitemapFetcherPlugin {
this._graphqlSitemapService = new GraphQLSitemapService({
endpoint: config.graphQLEndpoint,
apiKey: config.sitecoreApiKey,
sites: siteResolver.sites.map((site: SiteInfo) => site.name),
siteName: config.jssAppName,
});
}

async exec(context?: GetStaticPathsContext): Promise<StaticPath[]> {
if (process.env.EXPORT_MODE) {
ambrauer marked this conversation as resolved.
Show resolved Hide resolved
// Disconnected Export mode
if (process.env.JSS_MODE !== constants.JSS_MODE.DISCONNECTED) {
return this._graphqlSitemapService.fetchExportSitemap(config.defaultLanguage);
if (process.env.JSS_MODE === constants.JSS_MODE.DISCONNECTED) {
return [];
}
return process.env.EXPORT_MODE
? this._graphqlSitemapService.fetchExportSitemap(config.defaultLanguage)
: this._graphqlSitemapService.fetchSSGSitemap(context?.locales || []);
}
return this._graphqlSitemapService.fetchSSGSitemap(context?.locales || []);
}
Expand Down
5 changes: 5 additions & 0 deletions packages/sitecore-jss-nextjs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ export {
GraphQLSitemapServiceConfig,
} from './services/graphql-sitemap-service';

export {
MultisiteGraphQLSitemapService,
MultisiteGraphQLSitemapServiceConfig,
} from './services/mutisite-graphql-sitemap-service';

export {
GraphQLSitemapXmlService,
GraphQLSitemapXmlServiceConfig,
Expand Down
Loading