@littlebox/strapi-suite 1.0.34 → 1.0.36
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.
- package/README.md +149 -33
- package/dist/_chunks/{App-DyjWjB7j.mjs → App-2SwRpCFC.mjs} +111 -22
- package/dist/_chunks/{App-BHSmVWtI.js → App-DBXgA-D1.js} +111 -22
- package/dist/_chunks/{SlugInput-Blvf1j9x.mjs → SlugInput-BcUe-oCY.mjs} +2 -2
- package/dist/_chunks/{SlugInput-6ZNFcvBl.js → SlugInput-CVnNz0al.js} +2 -2
- package/dist/_chunks/{convertToSlug-CTdv5t0Z.js → convertToSlug-Btfca6aI.js} +1 -1
- package/dist/_chunks/{convertToSlug-Cc3NGUTL.mjs → convertToSlug-q9_W-VMA.mjs} +1 -1
- package/dist/_chunks/{en-B02DK8eB.js → en-CGJcJfk1.js} +3 -0
- package/dist/_chunks/{en-Gbpe0cex.mjs → en-CRSiVe4w.mjs} +3 -0
- package/dist/_chunks/{index-JYGAi1yZ.mjs → index-DmkEUACh.mjs} +10 -6
- package/dist/_chunks/{index-DXJ64IZL.js → index-Pylfg-hk.js} +7 -3
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/admin/src/core/config.d.ts +2 -0
- package/dist/server/index.js +138 -49
- package/dist/server/index.mjs +138 -49
- package/dist/server/src/config/index.d.ts +2 -0
- package/dist/server/src/controllers/index.d.ts +8 -0
- package/dist/server/src/controllers/modules/locales.d.ts +10 -0
- package/dist/server/src/index.d.ts +9 -7
- package/dist/server/src/services/index.d.ts +1 -7
- package/dist/server/src/services/modules/slug.d.ts +1 -7
- package/package.json +1 -1
|
@@ -57,6 +57,9 @@ const en = {
|
|
|
57
57
|
"littlebox-strapi-suite.module.slug.modal.settings.input.default-language.description": "Show language slug for default language in site url",
|
|
58
58
|
"littlebox-strapi-suite.module.slug.modal.settings.input.homepage.title": "Home page",
|
|
59
59
|
"littlebox-strapi-suite.module.slug.modal.settings.input.homepage.description": "The content that will be rendered as the homepage",
|
|
60
|
+
"littlebox-strapi-suite.module.slug.modal.settings.input.homepage-strategy.title": "Home page slug strategy",
|
|
61
|
+
"littlebox-strapi-suite.module.slug.modal.settings.input.homepage-strategy.description.language": "Use the language slug and ignore the content slug set as the homepage",
|
|
62
|
+
"littlebox-strapi-suite.module.slug.modal.settings.input.homepage-strategy.description.content": "Use the slug of the content set as the homepage",
|
|
60
63
|
"littlebox-strapi-suite.module.slug.modal.settings.button.save": "Save",
|
|
61
64
|
"littlebox-strapi-suite.module.attribute.name": "Attribute",
|
|
62
65
|
"littlebox-strapi-suite.module.attribute.description": "Effortlessly customize any page with simple and flexible attribute options.",
|
|
@@ -55,6 +55,9 @@ const en = {
|
|
|
55
55
|
"littlebox-strapi-suite.module.slug.modal.settings.input.default-language.description": "Show language slug for default language in site url",
|
|
56
56
|
"littlebox-strapi-suite.module.slug.modal.settings.input.homepage.title": "Home page",
|
|
57
57
|
"littlebox-strapi-suite.module.slug.modal.settings.input.homepage.description": "The content that will be rendered as the homepage",
|
|
58
|
+
"littlebox-strapi-suite.module.slug.modal.settings.input.homepage-strategy.title": "Home page slug strategy",
|
|
59
|
+
"littlebox-strapi-suite.module.slug.modal.settings.input.homepage-strategy.description.language": "Use the language slug and ignore the content slug set as the homepage",
|
|
60
|
+
"littlebox-strapi-suite.module.slug.modal.settings.input.homepage-strategy.description.content": "Use the slug of the content set as the homepage",
|
|
58
61
|
"littlebox-strapi-suite.module.slug.modal.settings.button.save": "Save",
|
|
59
62
|
"littlebox-strapi-suite.module.attribute.name": "Attribute",
|
|
60
63
|
"littlebox-strapi-suite.module.attribute.description": "Effortlessly customize any page with simple and flexible attribute options.",
|
|
@@ -2597,6 +2597,8 @@ function makeNodesHash(arr) {
|
|
|
2597
2597
|
return res;
|
|
2598
2598
|
}
|
|
2599
2599
|
const PLUGIN_ID = "littlebox-strapi-suite";
|
|
2600
|
+
const SLUG_LANGUAGE_STRATEGY = "language";
|
|
2601
|
+
const SLUG_CONTENT_STRATEGY = "content";
|
|
2600
2602
|
const config = {
|
|
2601
2603
|
pluginId: PLUGIN_ID,
|
|
2602
2604
|
uuid: {
|
|
@@ -3301,7 +3303,7 @@ const index = {
|
|
|
3301
3303
|
defaultMessage: config.pluginId
|
|
3302
3304
|
},
|
|
3303
3305
|
position: 999,
|
|
3304
|
-
Component: () => import("./App-
|
|
3306
|
+
Component: () => import("./App-2SwRpCFC.mjs")
|
|
3305
3307
|
});
|
|
3306
3308
|
app.customFields.register({
|
|
3307
3309
|
name: "ltbslug",
|
|
@@ -3319,7 +3321,7 @@ const index = {
|
|
|
3319
3321
|
components: {
|
|
3320
3322
|
Input: async () => import(
|
|
3321
3323
|
/* webpackChunkName: "input-slug-component" */
|
|
3322
|
-
"./SlugInput-
|
|
3324
|
+
"./SlugInput-BcUe-oCY.mjs"
|
|
3323
3325
|
)
|
|
3324
3326
|
},
|
|
3325
3327
|
options: {
|
|
@@ -3371,7 +3373,7 @@ const index = {
|
|
|
3371
3373
|
return Promise.all(
|
|
3372
3374
|
locales.map(async (locale) => {
|
|
3373
3375
|
try {
|
|
3374
|
-
const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./core/translations/en.json": () => import("./en-
|
|
3376
|
+
const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./core/translations/en.json": () => import("./en-CRSiVe4w.mjs") }), `./core/translations/${locale}.json`, 4);
|
|
3375
3377
|
return { data, locale };
|
|
3376
3378
|
} catch {
|
|
3377
3379
|
return { data: {}, locale };
|
|
@@ -3398,10 +3400,12 @@ export {
|
|
|
3398
3400
|
FetchSettings as F,
|
|
3399
3401
|
PageAttributeUpdated as P,
|
|
3400
3402
|
Registry as R,
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
+
SLUG_LANGUAGE_STRATEGY as S,
|
|
3404
|
+
SLUG_CONTENT_STRATEGY as a,
|
|
3405
|
+
FetchSlugs as b,
|
|
3403
3406
|
config as c,
|
|
3404
|
-
|
|
3407
|
+
PluginIcon as d,
|
|
3408
|
+
FetchModuleSettings as e,
|
|
3405
3409
|
fetchTemplates as f,
|
|
3406
3410
|
getTranslation as g,
|
|
3407
3411
|
index as i
|
|
@@ -2600,6 +2600,8 @@ function makeNodesHash(arr) {
|
|
|
2600
2600
|
return res;
|
|
2601
2601
|
}
|
|
2602
2602
|
const PLUGIN_ID = "littlebox-strapi-suite";
|
|
2603
|
+
const SLUG_LANGUAGE_STRATEGY = "language";
|
|
2604
|
+
const SLUG_CONTENT_STRATEGY = "content";
|
|
2603
2605
|
const config = {
|
|
2604
2606
|
pluginId: PLUGIN_ID,
|
|
2605
2607
|
uuid: {
|
|
@@ -3304,7 +3306,7 @@ const index = {
|
|
|
3304
3306
|
defaultMessage: config.pluginId
|
|
3305
3307
|
},
|
|
3306
3308
|
position: 999,
|
|
3307
|
-
Component: () => Promise.resolve().then(() => require("./App-
|
|
3309
|
+
Component: () => Promise.resolve().then(() => require("./App-DBXgA-D1.js"))
|
|
3308
3310
|
});
|
|
3309
3311
|
app.customFields.register({
|
|
3310
3312
|
name: "ltbslug",
|
|
@@ -3322,7 +3324,7 @@ const index = {
|
|
|
3322
3324
|
components: {
|
|
3323
3325
|
Input: async () => Promise.resolve().then(() => require(
|
|
3324
3326
|
/* webpackChunkName: "input-slug-component" */
|
|
3325
|
-
"./SlugInput-
|
|
3327
|
+
"./SlugInput-CVnNz0al.js"
|
|
3326
3328
|
))
|
|
3327
3329
|
},
|
|
3328
3330
|
options: {
|
|
@@ -3374,7 +3376,7 @@ const index = {
|
|
|
3374
3376
|
return Promise.all(
|
|
3375
3377
|
locales.map(async (locale) => {
|
|
3376
3378
|
try {
|
|
3377
|
-
const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./core/translations/en.json": () => Promise.resolve().then(() => require("./en-
|
|
3379
|
+
const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./core/translations/en.json": () => Promise.resolve().then(() => require("./en-CGJcJfk1.js")) }), `./core/translations/${locale}.json`, 4);
|
|
3378
3380
|
return { data, locale };
|
|
3379
3381
|
} catch {
|
|
3380
3382
|
return { data: {}, locale };
|
|
@@ -3403,6 +3405,8 @@ exports.FetchSlugs = FetchSlugs;
|
|
|
3403
3405
|
exports.PageAttributeUpdated = PageAttributeUpdated;
|
|
3404
3406
|
exports.PluginIcon = PluginIcon;
|
|
3405
3407
|
exports.Registry = Registry;
|
|
3408
|
+
exports.SLUG_CONTENT_STRATEGY = SLUG_CONTENT_STRATEGY;
|
|
3409
|
+
exports.SLUG_LANGUAGE_STRATEGY = SLUG_LANGUAGE_STRATEGY;
|
|
3406
3410
|
exports.config = config;
|
|
3407
3411
|
exports.fetchTemplates = fetchTemplates;
|
|
3408
3412
|
exports.getTranslation = getTranslation;
|
package/dist/admin/index.js
CHANGED
package/dist/admin/index.mjs
CHANGED
package/dist/server/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const PLUGIN_ID = "littlebox-strapi-suite";
|
|
3
|
+
const SLUG_LANGUAGE_STRATEGY = "language";
|
|
3
4
|
const config = {
|
|
4
5
|
default: {
|
|
5
6
|
pluginId: PLUGIN_ID,
|
|
@@ -434,19 +435,6 @@ const bootstrap = async ({ strapi: strapi2 }) => {
|
|
|
434
435
|
type: "boolean",
|
|
435
436
|
value: "false"
|
|
436
437
|
},
|
|
437
|
-
{
|
|
438
|
-
module: "template",
|
|
439
|
-
property: "active",
|
|
440
|
-
type: "boolean",
|
|
441
|
-
value: "true"
|
|
442
|
-
}
|
|
443
|
-
]
|
|
444
|
-
});
|
|
445
|
-
} catch (e) {
|
|
446
|
-
}
|
|
447
|
-
try {
|
|
448
|
-
await strapi2.db.query(config2.uuid.app.setting).createMany({
|
|
449
|
-
data: [
|
|
450
438
|
{
|
|
451
439
|
module: "slug",
|
|
452
440
|
property: "homepageContentId",
|
|
@@ -458,6 +446,24 @@ const bootstrap = async ({ strapi: strapi2 }) => {
|
|
|
458
446
|
property: "homepageContentModel",
|
|
459
447
|
type: "string",
|
|
460
448
|
value: null
|
|
449
|
+
},
|
|
450
|
+
{
|
|
451
|
+
module: "slug",
|
|
452
|
+
property: "homepageSlugStrategy",
|
|
453
|
+
type: "string",
|
|
454
|
+
value: "language"
|
|
455
|
+
},
|
|
456
|
+
{
|
|
457
|
+
module: "template",
|
|
458
|
+
property: "active",
|
|
459
|
+
type: "boolean",
|
|
460
|
+
value: "true"
|
|
461
|
+
},
|
|
462
|
+
{
|
|
463
|
+
module: "locale",
|
|
464
|
+
property: "active",
|
|
465
|
+
type: "boolean",
|
|
466
|
+
value: "true"
|
|
461
467
|
}
|
|
462
468
|
]
|
|
463
469
|
});
|
|
@@ -1193,6 +1199,17 @@ const TranslationModuleController = ({ strapi: strapi2 }) => ({
|
|
|
1193
1199
|
return await strapi2.plugin(PLUGIN_ID).service("TranslationModuleService").getTranslations();
|
|
1194
1200
|
}
|
|
1195
1201
|
});
|
|
1202
|
+
const LocalesModuleController = ({ strapi: strapi2 }) => ({
|
|
1203
|
+
async getLocales() {
|
|
1204
|
+
const locales = await strapi2.plugin("i18n").service("locales").find();
|
|
1205
|
+
const mappedLocales = locales.map((locale) => locale.code.toLowerCase());
|
|
1206
|
+
const defaultLocale = await strapi2.plugin("i18n").service("locales").getDefaultLocale();
|
|
1207
|
+
return {
|
|
1208
|
+
locales: mappedLocales,
|
|
1209
|
+
default: defaultLocale
|
|
1210
|
+
};
|
|
1211
|
+
}
|
|
1212
|
+
});
|
|
1196
1213
|
const controllers = {
|
|
1197
1214
|
SettingAppController,
|
|
1198
1215
|
SlugModuleController,
|
|
@@ -1200,10 +1217,12 @@ const controllers = {
|
|
|
1200
1217
|
TemplateModuleController,
|
|
1201
1218
|
MenuModuleController,
|
|
1202
1219
|
ParameterModuleController,
|
|
1203
|
-
TranslationModuleController
|
|
1220
|
+
TranslationModuleController,
|
|
1221
|
+
LocalesModuleController
|
|
1204
1222
|
};
|
|
1205
1223
|
function getModuleName(url) {
|
|
1206
1224
|
if (url.includes("/pages")) return "slug";
|
|
1225
|
+
if (url.includes("/locales")) return "locale";
|
|
1207
1226
|
if (url.includes("/parameters")) return "parameter";
|
|
1208
1227
|
if (url.includes("/translations")) return "translation";
|
|
1209
1228
|
if (url.includes("/menus")) return "menu";
|
|
@@ -1301,6 +1320,16 @@ const contentAPIRoutes = [
|
|
|
1301
1320
|
policies: ["check-api-token"],
|
|
1302
1321
|
auth: false
|
|
1303
1322
|
}
|
|
1323
|
+
},
|
|
1324
|
+
{
|
|
1325
|
+
method: "GET",
|
|
1326
|
+
path: "/modules/locales",
|
|
1327
|
+
handler: "LocalesModuleController.getLocales",
|
|
1328
|
+
config: {
|
|
1329
|
+
middlewares: [`plugin::${PLUGIN_ID}.check-module-is-active`],
|
|
1330
|
+
policies: ["check-api-token"],
|
|
1331
|
+
auth: false
|
|
1332
|
+
}
|
|
1304
1333
|
}
|
|
1305
1334
|
];
|
|
1306
1335
|
const adminAPIRoutes = [
|
|
@@ -1653,24 +1682,42 @@ const SlugModuleService = ({ strapi: strapi2 }) => ({
|
|
|
1653
1682
|
const ctx = strapi2.requestContext.get();
|
|
1654
1683
|
const config2 = strapi2.config.get(`plugin::${PLUGIN_ID}`);
|
|
1655
1684
|
const slug = ctx.query.slug.replace(/^\/|\/$/g, "");
|
|
1685
|
+
const locales = await strapi2.plugin("i18n").service("locales").find();
|
|
1686
|
+
const mappedLocales = locales.map((locale) => locale.code.toLowerCase());
|
|
1656
1687
|
const defaultLocale = await strapi2.plugin("i18n").service("locales").getDefaultLocale();
|
|
1657
|
-
const
|
|
1688
|
+
const settings = await strapi2.db.query(config2.uuid.app.setting).findMany({
|
|
1658
1689
|
where: {
|
|
1659
1690
|
module: "slug",
|
|
1660
|
-
property: "showDefaultLanguage"
|
|
1691
|
+
property: ["showDefaultLanguage", "homepageContentId", "homepageContentModel", "homepageSlugStrategy"]
|
|
1661
1692
|
}
|
|
1662
1693
|
});
|
|
1663
|
-
const showDefaultLanguage = setting.value === "true";
|
|
1664
|
-
const
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1694
|
+
const showDefaultLanguage = settings.find((setting) => setting.property === "showDefaultLanguage").value === "true";
|
|
1695
|
+
const homepageContentId = settings.find((setting) => setting.property === "homepageContentId").value;
|
|
1696
|
+
const homepageSlugStrategy = settings.find((setting) => setting.property === "homepageSlugStrategy").value;
|
|
1697
|
+
const homepageContentModel = settings.find((setting) => setting.property === "homepageContentModel").value;
|
|
1698
|
+
let page;
|
|
1699
|
+
if (homepageSlugStrategy === SLUG_LANGUAGE_STRATEGY && mappedLocales.includes(slug)) {
|
|
1700
|
+
page = await strapi2.db.query(config2.uuid.modules.slug).findOne({
|
|
1701
|
+
where: {
|
|
1702
|
+
state: "published",
|
|
1703
|
+
contentId: homepageContentId,
|
|
1704
|
+
contentModel: homepageContentModel,
|
|
1705
|
+
locale: slug
|
|
1706
|
+
}
|
|
1707
|
+
});
|
|
1708
|
+
page.fullSlug = slug;
|
|
1709
|
+
} else {
|
|
1710
|
+
const pages = await strapi2.db.query(config2.uuid.modules.slug).findMany({
|
|
1711
|
+
where: {
|
|
1712
|
+
state: "published",
|
|
1713
|
+
slug: slug.split("/")
|
|
1714
|
+
}
|
|
1715
|
+
});
|
|
1716
|
+
pages.forEach((page2) => {
|
|
1717
|
+
page2.fullSlug = buildFullSlug({ pages, page: page2, defaultLocale, showDefaultLanguage });
|
|
1718
|
+
});
|
|
1719
|
+
page = pages.find((page2) => page2.fullSlug === slug);
|
|
1720
|
+
}
|
|
1674
1721
|
if (!page) {
|
|
1675
1722
|
ctx.status = 404;
|
|
1676
1723
|
return;
|
|
@@ -1704,13 +1751,17 @@ const SlugModuleService = ({ strapi: strapi2 }) => ({
|
|
|
1704
1751
|
documentId: page.contentId
|
|
1705
1752
|
});
|
|
1706
1753
|
for (const localization of document.localizations) {
|
|
1707
|
-
localization.
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1754
|
+
if (homepageSlugStrategy === SLUG_LANGUAGE_STRATEGY && localization.documentId === homepageContentId) {
|
|
1755
|
+
localization.slug = localization.locale === defaultLocale ? "" : localization.locale.toLowerCase();
|
|
1756
|
+
} else {
|
|
1757
|
+
localization.slug = await getSlugByDocumentId({
|
|
1758
|
+
contentId: localization.documentId,
|
|
1759
|
+
locale: localization.locale,
|
|
1760
|
+
defaultLocale,
|
|
1761
|
+
showDefaultLanguage,
|
|
1762
|
+
strapi: strapi2
|
|
1763
|
+
});
|
|
1764
|
+
}
|
|
1714
1765
|
}
|
|
1715
1766
|
delete document.createdBy;
|
|
1716
1767
|
delete document.updatedBy;
|
|
@@ -1728,22 +1779,23 @@ const SlugModuleService = ({ strapi: strapi2 }) => ({
|
|
|
1728
1779
|
const settings = await strapi2.db.query(config2.uuid.app.setting).findMany({
|
|
1729
1780
|
where: {
|
|
1730
1781
|
module: "slug",
|
|
1731
|
-
property: ["showDefaultLanguage", "homepageContentId", "homepageContentModel"]
|
|
1782
|
+
property: ["showDefaultLanguage", "homepageContentId", "homepageContentModel", "homepageSlugStrategy"]
|
|
1732
1783
|
}
|
|
1733
1784
|
});
|
|
1734
1785
|
const showDefaultLanguage = settings.find((setting) => setting.property === "showDefaultLanguage").value === "true";
|
|
1735
1786
|
const homepageContentId = settings.find((setting) => setting.property === "homepageContentId").value;
|
|
1736
|
-
settings.find((setting) => setting.property === "homepageContentModel").value;
|
|
1787
|
+
const homepageContentModel = settings.find((setting) => setting.property === "homepageContentModel").value;
|
|
1788
|
+
const homepageSlugStrategy = settings.find((setting) => setting.property === "homepageSlugStrategy").value;
|
|
1737
1789
|
const pages = await strapi2.db.query(config2.uuid.modules.slug).findMany({
|
|
1738
1790
|
where: {
|
|
1739
1791
|
state: "published"
|
|
1740
1792
|
}
|
|
1741
1793
|
});
|
|
1742
1794
|
pages.forEach((page) => {
|
|
1743
|
-
if (homepageContentId === page.contentId && defaultLocale === page.locale) {
|
|
1795
|
+
if (homepageContentId === page.contentId && homepageContentModel === page.contentModel && defaultLocale === page.locale) {
|
|
1744
1796
|
page.fullSlug = "";
|
|
1745
|
-
} else if (homepageContentId === page.contentId && defaultLocale !== page.locale) {
|
|
1746
|
-
page.fullSlug = page.locale;
|
|
1797
|
+
} else if (homepageContentId === page.contentId && homepageContentModel === page.contentModel && defaultLocale !== page.locale && homepageSlugStrategy === SLUG_LANGUAGE_STRATEGY) {
|
|
1798
|
+
page.fullSlug = page.locale.toLowerCase();
|
|
1747
1799
|
} else {
|
|
1748
1800
|
page.fullSlug = buildFullSlug({ pages, page, defaultLocale, showDefaultLanguage });
|
|
1749
1801
|
}
|
|
@@ -1772,13 +1824,37 @@ const SlugModuleService = ({ strapi: strapi2 }) => ({
|
|
|
1772
1824
|
}
|
|
1773
1825
|
}
|
|
1774
1826
|
const mappedPages = pages.map((page) => ({
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
locale: page.locale,
|
|
1779
|
-
...page.attributes ? { attributes: page.attributes } : {}
|
|
1827
|
+
...page,
|
|
1828
|
+
...page.attributes ? { attributes: page.attributes } : {},
|
|
1829
|
+
localizations: []
|
|
1780
1830
|
}));
|
|
1781
|
-
|
|
1831
|
+
const rootItems = mappedPages.filter((item) => item.locale === defaultLocale);
|
|
1832
|
+
const mappedItems = rootItems.map((rootItem) => {
|
|
1833
|
+
const relatedItems = mappedPages.filter(
|
|
1834
|
+
(item) => item.contentId === rootItem.contentId && item.contentModel === rootItem.contentModel && item.locale !== defaultLocale
|
|
1835
|
+
);
|
|
1836
|
+
return {
|
|
1837
|
+
id: rootItem.id,
|
|
1838
|
+
documentId: rootItem.contentId,
|
|
1839
|
+
slug: rootItem.fullSlug,
|
|
1840
|
+
locale: rootItem.locale,
|
|
1841
|
+
createdAt: rootItem.updatedAt,
|
|
1842
|
+
updatedAt: rootItem.updatedAt,
|
|
1843
|
+
publishedAt: rootItem.updatedAt,
|
|
1844
|
+
...rootItem.attributes ? { attributes: rootItem.attributes } : {},
|
|
1845
|
+
localizations: relatedItems.map((item) => ({
|
|
1846
|
+
id: item.id,
|
|
1847
|
+
documentId: item.contentId,
|
|
1848
|
+
slug: item.fullSlug,
|
|
1849
|
+
locale: item.locale,
|
|
1850
|
+
createdAt: item.updatedAt,
|
|
1851
|
+
updatedAt: item.updatedAt,
|
|
1852
|
+
publishedAt: item.updatedAt,
|
|
1853
|
+
...item.attributes ? { attributes: item.attributes } : {}
|
|
1854
|
+
}))
|
|
1855
|
+
};
|
|
1856
|
+
});
|
|
1857
|
+
return mappedItems;
|
|
1782
1858
|
},
|
|
1783
1859
|
async getHomePage() {
|
|
1784
1860
|
const ctx = strapi2.requestContext.get();
|
|
@@ -1787,16 +1863,19 @@ const SlugModuleService = ({ strapi: strapi2 }) => ({
|
|
|
1787
1863
|
const settings = await strapi2.db.query(config2.uuid.app.setting).findMany({
|
|
1788
1864
|
where: {
|
|
1789
1865
|
module: "slug",
|
|
1790
|
-
property: ["homepageContentId", "homepageContentModel"]
|
|
1866
|
+
property: ["showDefaultLanguage", "homepageContentId", "homepageContentModel", "homepageSlugStrategy"]
|
|
1791
1867
|
}
|
|
1792
1868
|
});
|
|
1869
|
+
const showDefaultLanguage = settings.find((setting) => setting.property === "showDefaultLanguage").value === "true";
|
|
1793
1870
|
const homepageContentId = settings.find((setting) => setting.property === "homepageContentId").value;
|
|
1794
1871
|
const homepageContentModel = settings.find((setting) => setting.property === "homepageContentModel").value;
|
|
1872
|
+
const homepageSlugStrategy = settings.find((setting) => setting.property === "homepageSlugStrategy").value;
|
|
1795
1873
|
const page = await strapi2.db.query(config2.uuid.modules.slug).findOne({
|
|
1796
1874
|
where: {
|
|
1797
1875
|
state: "published",
|
|
1798
1876
|
contentId: homepageContentId,
|
|
1799
|
-
contentModel: homepageContentModel
|
|
1877
|
+
contentModel: homepageContentModel,
|
|
1878
|
+
locale: defaultLocale
|
|
1800
1879
|
}
|
|
1801
1880
|
});
|
|
1802
1881
|
if (!page) {
|
|
@@ -1832,11 +1911,21 @@ const SlugModuleService = ({ strapi: strapi2 }) => ({
|
|
|
1832
1911
|
documentId: page.contentId
|
|
1833
1912
|
});
|
|
1834
1913
|
for (const localization of document.localizations) {
|
|
1835
|
-
|
|
1914
|
+
if (homepageSlugStrategy === SLUG_LANGUAGE_STRATEGY) {
|
|
1915
|
+
localization.slug = localization.locale === defaultLocale ? "" : localization.locale.toLowerCase();
|
|
1916
|
+
} else {
|
|
1917
|
+
localization.slug = await getSlugByDocumentId({
|
|
1918
|
+
contentId: localization.documentId,
|
|
1919
|
+
locale: localization.locale,
|
|
1920
|
+
defaultLocale,
|
|
1921
|
+
showDefaultLanguage,
|
|
1922
|
+
strapi: strapi2
|
|
1923
|
+
});
|
|
1924
|
+
}
|
|
1836
1925
|
}
|
|
1837
1926
|
delete document.createdBy;
|
|
1838
1927
|
delete document.updatedBy;
|
|
1839
|
-
document.slug =
|
|
1928
|
+
document.slug = "";
|
|
1840
1929
|
return {
|
|
1841
1930
|
document,
|
|
1842
1931
|
...page.attributes ? { attributes: page.attributes } : {}
|