diff --git a/layout/_partial/sidebar/index.ejs b/layout/_partial/sidebar/index.ejs index f24dd2c..be4262a 100755 --- a/layout/_partial/sidebar/index.ejs +++ b/layout/_partial/sidebar/index.ejs @@ -73,11 +73,21 @@ function layoutWidgets() { } if (page.sidebar) { page.sidebar.forEach((w, i) => { - if (w in theme.data.widgets) { - let widget = theme.data.widgets[w]; - if (widget && widget.layout) { - el += partial('widgets/' + widget.layout, {item: widget}); - } + let name = '' + if (typeof w == 'string') { + name = w + } else if (typeof w == 'object' && w.layout && w.override) { + name = w.override + } + let widget = {} + if (name in theme.data.widgets) { + Object.assign(widget, theme.data.widgets[name]) + } + if (typeof w == 'object' && w.layout) { + Object.assign(widget, w) + } + if (widget && widget.layout) { + el += partial('widgets/' + widget.layout, {item: widget}) } }); } diff --git a/layout/_partial/sidebar/widgets/markdown.ejs b/layout/_partial/sidebar/widgets/markdown.ejs index 3ddb2f5..df087c1 100644 --- a/layout/_partial/sidebar/widgets/markdown.ejs +++ b/layout/_partial/sidebar/widgets/markdown.ejs @@ -1,16 +1,16 @@ <% function layoutDiv() { + if (!item.content?.length) return '' var el = ''; - if (item.content == undefined || item.content.length == 0) { - return el; - } el += '
'; + if (item.title?.length > 0) { el += '
'; - el += '' + item.title + ''; - el += '
'; - el += '
'; - el += markdown(item.content); + el += '' + item.title + ''; el += '
'; + } + el += '
'; + el += markdown(item.content); + el += '
'; el += '
'; return el; }