You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
2.1 KiB

6 years ago
<% if (config.widgets){ %>
<% (config.widgets||[]).forEach(function(item){ %>
<% if (item.enable != false){ %>
<%
let widget_name = item.widget ? item.widget : 'plain';
var needDisplay = true;
if (needDisplay == true && widget_name == 'toc') {
if (page.layout != 'post' || !page.content || page.toc == false || toc(page.content).length == 0) {
needDisplay = false;
}
}
if (needDisplay == true && widget_name == 'music') {
if (page.layout != 'post' || !page.content || page.toc == false || toc(page.content).length == 0) {
needDisplay = false;
}
}
if (needDisplay) {
needDisplay = ((widget_name != 'toc') || (page.layout == 'post' && page.content && page.toc!==false && toc(page.content).length > 0));
}
%>
<% if (needDisplay){ %>
<section class='<%- widget_name == 'toc' ? 'toc-wrapper' : widget_name %>'>
<% if (widget_name != 'author'){ %>
<header class='<%= theme.style %>'>
<div><i class="<%- item.icon %> fa-fw" aria-hidden="true"></i>&nbsp;&nbsp;<%- item.title %></div>
<% if (widget_name == 'toc') { %>
<div class='wrapper'><a class="s-toc rightBtn" title="固定到顶部" rel="external nofollow noopener noreferrer" href="javascript:void(0)"><i class="fas fa-thumbtack fa-fw"></i></a></div>
<% } else if(item.more && item.more.url) { %>
6 years ago
<a class="rightBtn<%- item.more.animate ? ' ' + item.more.animate : '' %>" target="_blank"
6 years ago
rel="external nofollow noopener noreferrer"
href="<%- url_for(item.more.url) %>"
title="<%- item.more.url %>">
<i class="<%- item.more.icon?item.more.icon:'fas fa-question-circle' %> fa-fw"></i></a>
<% } %>
6 years ago
</header>
<% } %>
<div class='content <%= theme.style %>'>
<%- partial('../_widget/' + widget_name, {item: item}) %>
</div>
</section>
6 years ago
<% } %>
<% } %>
6 years ago
<% }) %>
<% } %>