diff --git a/public/src/widgets.js b/public/src/widgets.js index 494546c023..de2d0e8697 100644 --- a/public/src/widgets.js +++ b/public/src/widgets.js @@ -9,17 +9,18 @@ module.exports.render = function (template) { locations.forEach(function (location) { let area = $('#content [widget-area="' + location + '"],#content [data-widget-area="' + location + '"]').eq(0); - if (area.length) { + const widgetsAtLocation = ajaxify.data.widgets[location] || []; + if (area.length || !widgetsAtLocation.length) { return; } - const widgetsAtLocation = ajaxify.data.widgets[location] || []; let html = ''; - widgetsAtLocation.forEach(function (widget) { html += widget.html; }); - + if (!html) { + return; + } if (location === 'footer' && !$('#content [widget-area="footer"],#content [data-widget-area="footer"]').length) { $('#content').append($('
')); } else if (location === 'sidebar' && !$('#content [widget-area="sidebar"],#content [data-widget-area="sidebar"]').length) { diff --git a/src/widgets/index.js b/src/widgets/index.js index 473a33a820..03b765740a 100644 --- a/src/widgets/index.js +++ b/src/widgets/index.js @@ -27,7 +27,7 @@ widgets.render = async function (uid, options) { const returnData = {}; locations.forEach((location, i) => { if (Array.isArray(widgetData[i]) && widgetData[i].length) { - returnData[location] = widgetData[i].filter(Boolean); + returnData[location] = widgetData[i].filter(widget => widget && widget.html); } });