@websolutespa/bom-core 1.8.5 → 1.8.7
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/CHANGELOG.md +12 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +18 -1
- package/dist/index.mjs +18 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1041,7 +1041,7 @@ declare enum RouteStrategy {
|
|
|
1041
1041
|
* @param locales - The list of locales.
|
|
1042
1042
|
* @returns An array of collected routes.
|
|
1043
1043
|
*/
|
|
1044
|
-
declare function collectRoutes(store: IMemoryStore<ICategorized>, categories: ICategory[], markets: IMarket[], locales: ILocale[]): IRoute[];
|
|
1044
|
+
declare function collectRoutes(store: IMemoryStore<ICategorized>, categories: ICategory[], markets: IMarket[], locales: ILocale[], medias?: IMedia[]): IRoute[];
|
|
1045
1045
|
/**
|
|
1046
1046
|
* Iterates over each market and locale combination and invokes the callback function.
|
|
1047
1047
|
*
|
package/dist/index.js
CHANGED
|
@@ -1386,7 +1386,7 @@ function getPickedProps(item) {
|
|
|
1386
1386
|
].includes(k)));
|
|
1387
1387
|
return pickedProps;
|
|
1388
1388
|
}
|
|
1389
|
-
function collectRoutes(store, categories, markets, locales) {
|
|
1389
|
+
function collectRoutes(store, categories, markets, locales, medias) {
|
|
1390
1390
|
const routes = [];
|
|
1391
1391
|
if (locales.length > 0 && markets.length > 0) {
|
|
1392
1392
|
const rootCategory = getRootCategory(categories);
|
|
@@ -1415,12 +1415,22 @@ function collectRoutes(store, categories, markets, locales) {
|
|
|
1415
1415
|
schema: key,
|
|
1416
1416
|
title
|
|
1417
1417
|
};
|
|
1418
|
+
const mediaId = typeof item.media === "string" ? item.media : void 0;
|
|
1419
|
+
if (Array.isArray(medias) && mediaId) {
|
|
1420
|
+
const media = item.media && medias.find((x) => x.id === mediaId);
|
|
1421
|
+
if (media) {
|
|
1422
|
+
route.media = media;
|
|
1423
|
+
}
|
|
1424
|
+
}
|
|
1418
1425
|
routes.push(route);
|
|
1419
1426
|
}
|
|
1420
1427
|
eachMarketLocale(markets, locales, (market, locale, markets2, locales2) => {
|
|
1421
1428
|
if (!item.markets || item.markets.includes(market.id)) {
|
|
1422
1429
|
const title = localize(item.title, locale.id);
|
|
1423
1430
|
const id = getRouteHref(slugs, market, locale, markets2, locales2);
|
|
1431
|
+
if (!id) {
|
|
1432
|
+
return;
|
|
1433
|
+
}
|
|
1424
1434
|
const pickedProps = getPickedProps(item);
|
|
1425
1435
|
const route = {
|
|
1426
1436
|
...pickedProps,
|
|
@@ -1432,6 +1442,13 @@ function collectRoutes(store, categories, markets, locales) {
|
|
|
1432
1442
|
schema: key,
|
|
1433
1443
|
title
|
|
1434
1444
|
};
|
|
1445
|
+
const mediaId = typeof item.media === "string" ? item.media : void 0;
|
|
1446
|
+
if (Array.isArray(medias) && mediaId) {
|
|
1447
|
+
const media = item.media && medias.find((x) => x.id === mediaId);
|
|
1448
|
+
if (media) {
|
|
1449
|
+
route.media = media;
|
|
1450
|
+
}
|
|
1451
|
+
}
|
|
1435
1452
|
routes.push(route);
|
|
1436
1453
|
}
|
|
1437
1454
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -1238,7 +1238,7 @@ function getPickedProps(item) {
|
|
|
1238
1238
|
].includes(k)));
|
|
1239
1239
|
return pickedProps;
|
|
1240
1240
|
}
|
|
1241
|
-
function collectRoutes(store, categories, markets, locales) {
|
|
1241
|
+
function collectRoutes(store, categories, markets, locales, medias) {
|
|
1242
1242
|
const routes = [];
|
|
1243
1243
|
if (locales.length > 0 && markets.length > 0) {
|
|
1244
1244
|
const rootCategory = getRootCategory(categories);
|
|
@@ -1267,12 +1267,22 @@ function collectRoutes(store, categories, markets, locales) {
|
|
|
1267
1267
|
schema: key,
|
|
1268
1268
|
title
|
|
1269
1269
|
};
|
|
1270
|
+
const mediaId = typeof item.media === "string" ? item.media : void 0;
|
|
1271
|
+
if (Array.isArray(medias) && mediaId) {
|
|
1272
|
+
const media = item.media && medias.find((x) => x.id === mediaId);
|
|
1273
|
+
if (media) {
|
|
1274
|
+
route.media = media;
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1270
1277
|
routes.push(route);
|
|
1271
1278
|
}
|
|
1272
1279
|
eachMarketLocale(markets, locales, (market, locale, markets2, locales2) => {
|
|
1273
1280
|
if (!item.markets || item.markets.includes(market.id)) {
|
|
1274
1281
|
const title = localize(item.title, locale.id);
|
|
1275
1282
|
const id = getRouteHref(slugs, market, locale, markets2, locales2);
|
|
1283
|
+
if (!id) {
|
|
1284
|
+
return;
|
|
1285
|
+
}
|
|
1276
1286
|
const pickedProps = getPickedProps(item);
|
|
1277
1287
|
const route = {
|
|
1278
1288
|
...pickedProps,
|
|
@@ -1284,6 +1294,13 @@ function collectRoutes(store, categories, markets, locales) {
|
|
|
1284
1294
|
schema: key,
|
|
1285
1295
|
title
|
|
1286
1296
|
};
|
|
1297
|
+
const mediaId = typeof item.media === "string" ? item.media : void 0;
|
|
1298
|
+
if (Array.isArray(medias) && mediaId) {
|
|
1299
|
+
const media = item.media && medias.find((x) => x.id === mediaId);
|
|
1300
|
+
if (media) {
|
|
1301
|
+
route.media = media;
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1287
1304
|
routes.push(route);
|
|
1288
1305
|
}
|
|
1289
1306
|
});
|