@zeropress/build-core 0.1.13 → 0.1.14

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeropress/build-core",
3
- "version": "0.1.13",
3
+ "version": "0.1.14",
4
4
  "description": "Shared ZeroPress build core",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -272,7 +272,7 @@ function normalizePreviewData(previewData) {
272
272
  return {
273
273
  ...previewData,
274
274
  site: normalizedSite,
275
- widgets: normalizeWidgetAreas(previewData.widgets),
275
+ widgets: normalizeWidgetAreas(previewData.widgets, normalizedSite.mediaBaseUrl),
276
276
  custom_css: normalizeCustomCss(previewData.custom_css),
277
277
  content: {
278
278
  ...previewData.content,
@@ -298,7 +298,7 @@ function normalizePreviewData(previewData) {
298
298
  };
299
299
  }
300
300
 
301
- function normalizeWidgetAreas(widgetAreas) {
301
+ function normalizeWidgetAreas(widgetAreas, mediaBaseUrl) {
302
302
  if (!widgetAreas || typeof widgetAreas !== 'object') {
303
303
  return {};
304
304
  }
@@ -310,16 +310,32 @@ function normalizeWidgetAreas(widgetAreas) {
310
310
  ...widgetArea,
311
311
  name: normalizeNonEmptyString(widgetArea?.name, widgetAreaId),
312
312
  items: Array.isArray(widgetArea?.items)
313
- ? widgetArea.items.map((item) => ({
314
- ...item,
315
- title: normalizeNonEmptyString(item?.title, 'Widget'),
316
- }))
313
+ ? widgetArea.items.map((item) => normalizeWidgetItem(item, mediaBaseUrl))
317
314
  : [],
318
315
  },
319
316
  ]),
320
317
  );
321
318
  }
322
319
 
320
+ function normalizeWidgetItem(item, mediaBaseUrl) {
321
+ const normalizedItem = {
322
+ ...item,
323
+ title: normalizeNonEmptyString(item?.title, 'Widget'),
324
+ };
325
+
326
+ if (item?.type === 'profile' && item?.settings && typeof item.settings === 'object') {
327
+ return {
328
+ ...normalizedItem,
329
+ settings: {
330
+ ...item.settings,
331
+ avatar: normalizeMediaField(item.settings.avatar, mediaBaseUrl),
332
+ },
333
+ };
334
+ }
335
+
336
+ return normalizedItem;
337
+ }
338
+
323
339
  function normalizeCustomCss(customCss) {
324
340
  const content = normalizeOptionalString(customCss?.content);
325
341
  return content ? { content } : undefined;