Skip to content

Commit 52417df

Browse files
committed
fix: sitemap generation issue when the i18n plugin is not installed
1 parent da0f486 commit 52417df

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@pluginpal/webtools-addon-sitemap": patch
3+
---
4+
5+
Fix Sitemap generation issue when the i18n plugin is not installed

packages/addons/sitemap/server/services/core.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,13 @@ const getSitemapPageData = async (config, page, contentType, defaultLocale) => {
145145
*/
146146
const createSitemapEntries = async () => {
147147
const config = await getService('settings').getConfig();
148-
const { getDefaultLocale } = strapi.plugin('i18n').service('locales');
149-
const defaultLocale = await getDefaultLocale();
148+
let defaultLocale;
149+
150+
if (strapi.plugin('i18n')) {
151+
const { getDefaultLocale } = strapi.plugin('i18n').service('locales');
152+
defaultLocale = await getDefaultLocale();
153+
}
154+
150155
const sitemapEntries = [];
151156

152157
// Collection entries.

packages/addons/sitemap/server/services/query.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ import { noLimit, logMessage } from '../utils';
2222
*/
2323
const getPages = async (config, contentType, ids) => {
2424
const excludeDrafts = config.excludeDrafts && strapi.contentTypes[contentType].options.draftAndPublish;
25-
const isLocalized = strapi.contentTypes[contentType].pluginOptions?.i18n?.localized;
25+
const isLocalized =
26+
strapi.contentTypes[contentType].pluginOptions?.i18n?.localized
27+
&& strapi.plugin('i18n');
2628

2729
const pages = await noLimit(strapi, contentType, {
2830
filters: {
@@ -87,7 +89,10 @@ const getPages = async (config, contentType, ids) => {
8789
* @returns {object} The pages.
8890
*/
8991
const getLocalizationIds = async (contentType, ids) => {
90-
const isLocalized = strapi.contentTypes[contentType].pluginOptions?.i18n?.localized;
92+
const isLocalized =
93+
strapi.contentTypes[contentType].pluginOptions?.i18n?.localized
94+
&& strapi.plugin('i18n');
95+
9196
const localizationIds = [];
9297

9398
if (isLocalized) {

0 commit comments

Comments
 (0)