Skip to content

Commit

Permalink
fix: yml string to list
Browse files Browse the repository at this point in the history
  • Loading branch information
MHuiG committed Nov 24, 2022
1 parent 302bf4e commit 11ab545
Show file tree
Hide file tree
Showing 25 changed files with 54 additions and 47 deletions.
2 changes: 1 addition & 1 deletion layout/_partial/_cover/dock.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<div class='menu navigation'>
<div class='list-h'>
<% if (theme.cover.features) { %>
<% (theme.cover.features || []).forEach(function(value){ %>
<% getList(theme.cover.features).forEach(function(value){ %>
<a href="<%= url_for(value.url) %>"
<% if (value.rel) { %>
rel="<%- value.rel %>"
Expand Down
2 changes: 1 addition & 1 deletion layout/_partial/_cover/featured.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<div class='menu navigation'>
<div class='list-h'>
<% if (theme.cover.features) { %>
<% (theme.cover.features || []).forEach(function(value){ %>
<% getList(theme.cover.features).forEach(function(value){ %>
<a href="<%= url_for(value.url) %>"
<% if (value.rel) { %>
rel="<%- value.rel %>"
Expand Down
2 changes: 1 addition & 1 deletion layout/_partial/_cover/focus.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<div class='menu navigation'>
<div class='list-h'>
<% if (theme.cover.features) { %>
<% (theme.cover.features || []).forEach(function(value){ %>
<% getList(theme.cover.features).forEach(function(value){ %>
<a href="<%= url_for(value.url) %>"
<% if (value.rel) { %>
rel="<%- value.rel %>"
Expand Down
2 changes: 1 addition & 1 deletion layout/_partial/_cover/search.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<div class='menu navigation'>
<div class='list-h'>
<% if (theme.cover.features) { %>
<% (theme.cover.features || []).forEach(function(value){ %>
<% getList(theme.cover.features).forEach(function(value){ %>
<a href="<%= url_for(value.url) %>"
<% if (value.rel) { %>
rel="<%- value.rel %>"
Expand Down
6 changes: 3 additions & 3 deletions layout/_partial/article.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
</section>
<section class='body'>
<ul>
<% (page.references||[]).forEach(function(row){ %>
<% getList(page.references).forEach(function(row){ %>
<li>
<a href="<%- url_for(row.url) %>" rel="external nofollow noopener noreferrer" target="_blank">
<%- row.title || url_for(row.url) %>
Expand Down Expand Up @@ -104,7 +104,7 @@
<% } else { %>
<div class='copyright'>
<blockquote>
<% (footer_widget.copyright.content||[]).forEach(function(row){ %>
<% getList(footer_widget.copyright.content).forEach(function(row){ %>
<% if (row == 'permalink') { %>
<p><%- footer_widget.copyright.permalink %><a href="<%- decodeURI(page.permalink) %>"><%- decodeURI(page.permalink) %></a></p>
<% } else { %>
Expand All @@ -119,7 +119,7 @@
<% if (['post'].includes(page.layout) && footer_widget.donate && footer_widget.donate.enable == true) { %>
<div class='donate'>
<div class='imgs'>
<% (footer_widget.donate.images||[]).forEach(function(url){ %>
<% getList(footer_widget.donate.images).forEach(function(url){ %>
<img src='<%- url_for(url) %>'>
<% }) %>
</div>
Expand Down
2 changes: 1 addition & 1 deletion layout/_partial/footer.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<% if (item == 'social') { %>
<br>
<div class="social-wrapper" itemprop="about" itemscope itemtype="http://schema.org/Thing">
<% (theme.site_footer.social||[]).forEach(function(value){ %>
<% getList(theme.site_footer.social).forEach(function(value){ %>
<% if (value.url && (value.icon || value.img || value.avatar)) { %>
<a href="<%= url_for(value.url) %>"
class="social <%- value.icon %> flat-btn"
Expand Down
16 changes: 6 additions & 10 deletions layout/_partial/head.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<!-- 渲染优化 -->
<%_ if (theme.dns_prefetch && theme.dns_prefetch.length){ _%>
<meta http-equiv='x-dns-prefetch-control' content='on' />
<%_ ([...theme.dns_prefetch]).forEach(function(item){ _%>
<%_ getList(theme.dns_prefetch).forEach(function(item){ _%>
<link rel='dns-prefetch' href='<%- item %>'>
<link rel="preconnect" href="<%- item %>" crossorigin>
<%_ }) _%>
Expand All @@ -26,7 +26,7 @@
<meta content="telephone=no" name="format-detection">
<!-- import head_begin begin -->
<%_ if (config.import && config.import.head_begin){ _%>
<%_ ([...config.import.head_begin]).forEach(function(item){ _%>
<%_ getList(config.import.head_begin).forEach(function(item){ _%>
<%- item %>
<%_ }) _%>
<%_ } _%>
Expand All @@ -41,13 +41,9 @@
<%- generate_preload_fontfamily(theme) %>
<!-- feed -->
<%_ if (config.feed && config.feed.path){ _%>
<%_ if (typeof(config.feed.path)=="string"){ _%>
<%- feed_tag(config.feed.path, {title: config.title}) %>
<%_ }else{ _%>
<%_ ([...config.feed.path]).forEach(function(item){ _%>
<%- feed_tag(item, {title: config.title}) %>
<%_ }) _%>
<%_ } _%>
<%_ getList(config.feed.path).forEach(function(item){ _%>
<%- feed_tag(item, {title: config.title}) %>
<%_ }) _%>
<%_ } _%>
<!-- 页面元数据 -->
<%- generate_title(config, theme, page) %>
Expand All @@ -72,7 +68,7 @@
<%- partial('scripts/global') %>
<!-- import head_end begin -->
<%_ if (config.import && config.import.head_end){ _%>
<%_ ([...config.import.head_end]).forEach(function(item){ _%>
<%_ getList(config.import.head_end).forEach(function(item){ _%>
<%- item %>
<%_ }) _%>
<%_ } _%>
Expand Down
6 changes: 3 additions & 3 deletions layout/_partial/header.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@
</a>
<% if (value.rows) { %>
<ul class="list-v">
<% value.rows.forEach(function(value){ %>
<% getList(value.rows).forEach(function(value){ %>
<% menu(value, type) %>
<%})%>
</ul>
<% } %>
</li>
<% } %>
<% } %>
<% menu_list.forEach(function(value){ %>
<% getList(menu_list).forEach(function(value){ %>
<% menu(value, 'pc') %>
<% }) %>
</ul>
Expand All @@ -106,7 +106,7 @@
<li>
<a class="s-menu fa-solid fa-bars fa-fw" target="_self" href="/" onclick="return false;" title="menu"></a>
<ul class="menu-phone list-v navigation white-box">
<% menu_list.forEach(function(value){ %>
<% getList(menu_list).forEach(function(value){ %>
<% menu(value, 'mobile') %>
<% }) %>
</ul>
Expand Down
4 changes: 2 additions & 2 deletions layout/_partial/meta.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ if (post.bottom_meta == false) {
<%- post.title %>
</h1>
<div class='new-meta-box'>
<% (topMetas).forEach(function(meta) { %>
<% getList(topMetas).forEach(function(meta) { %>
<% if (meta in theme.article.body.meta_library){ %>
<%- partial('../_meta/' + meta, {post: post}) %>
<% } %>
Expand All @@ -53,7 +53,7 @@ if (post.bottom_meta == false) {
<% } else if (position == 'bottom') { %>
<div class='article-meta' id="bottom">
<div class='new-meta-box'>
<% (bottomMetas).forEach(function(meta){ %>
<% getList(bottomMetas).forEach(function(meta){ %>
<% if (meta in theme.article.body.meta_library) { %>
<%- partial('../_meta/' + meta, {post: post}) %>
<% } %>
Expand Down
6 changes: 3 additions & 3 deletions layout/_plugins/_page_plugins/index.ejs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<%_
(page.plugins||[]).forEach(function(item){
getList(page.plugins).forEach(function(item){
try {
if (typeof item == "string") { _%>
<%- partial( item + "/index") %>
Expand All @@ -13,12 +13,12 @@
没有找到页面插件:${item}
请检查是否存在该插件,或者检查插件名称是否正确:${item}
出问题的页面:${page.path}
see: https://volantis.js.org/v5/page-settings/#页面插件-page-plugins
see: https://volantis.js.org/v6/page-settings/#页面插件-page-plugins
================================================================================
There is no page plugin: ${item}
Please check if the plugin exists, or check the plugin name is correct: ${item}
The page that has problem: ${page.path}
see: https://volantis.js.org/v5/page-settings/#页面插件-page-plugins
see: https://volantis.js.org/v6/page-settings/#页面插件-page-plugins
=================================================================================`);
}
Expand Down
4 changes: 2 additions & 2 deletions layout/_plugins/highlight/prismjs/script.ejs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<% (theme.plugins.prismjs.js||[]).forEach(function(item) { %>
<% getList(theme.plugins.prismjs.js).forEach(function(item) { %>
<%- js(item) %>
<% }) %>
<% (theme.plugins.prismjs.css||[]).forEach(function(item) { %>
<% getList(theme.plugins.prismjs.css).forEach(function(item) { %>
<%- css(item) %>
<% }) %>
<script>
Expand Down
2 changes: 1 addition & 1 deletion layout/_plugins/share/layout.ejs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="new-meta-item share -mob-share-list">
<div class="-mob-share-list share-body">
<% (theme.article.body.meta_library.share||[]).forEach(function(item){ %>
<% getList(theme.article.body.meta_library.share).forEach(function(item){ %>
<% if (item.id == 'qrcode'){ %>
<% var src = qrcode(url,{margin:1,size:8}); %>
<div class='hoverbox'>
Expand Down
2 changes: 1 addition & 1 deletion layout/_widget/_pre.ejs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<%
var pf = [];
if (item.display) {
item.display.forEach(function(p){
getList(item.display).forEach(function(p){
pf.push(p);
});
} else {
Expand Down
2 changes: 1 addition & 1 deletion layout/_widget/blogger.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<% } %>
<% if (item.social && item.social.length > 0) { %>
<div class="social-wrapper">
<% (item.social||[]).forEach(function(value){ %>
<% getList(item.social).forEach(function(value){ %>
<% if (value.url && (value.icon || value.img || value.avatar)) { %>
<a href="<%= url_for(value.url) %>"
class="social <%- value.icon %> flat-btn"
Expand Down
4 changes: 2 additions & 2 deletions layout/_widget/copyright.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class='content'>
<% if (item.blockquote == true) { %>
<blockquote>
<% (item.content||[]).forEach(function(row){ %>
<% getList(item.content).forEach(function(row){ %>
<% if (row == 'permalink') { %>
<p><%- item.permalink %><a href=<%- page.permalink %>><%- page.permalink %></a></p>
<% } else { %>
Expand All @@ -12,7 +12,7 @@
<% }) %>
</blockquote>
<% } else { %>
<% (item.content||[]).forEach(function(row){ %>
<% getList(item.content).forEach(function(row){ %>
<% if (row == 'permalink') { %>
<p><%- item.permalink %><a href=<%- page.permalink %>><%- page.permalink %></a></p>
<% } else { %>
Expand Down
2 changes: 1 addition & 1 deletion layout/_widget/grid.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<%- partial('header', {item: item}) %>
<div class='content'>
<div class="grid navigation<%- item.fixed ? ' fixed' : '' %>">
<% (item.rows||[]).forEach(function(row){ %>
<% getList(item.rows).forEach(function(row){ %>
<a class="flat-box" href="<%- url_for(row.url) %>"
<% if (row.rel) { %>
rel="<%- row.rel %>"
Expand Down
2 changes: 1 addition & 1 deletion layout/_widget/list.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<%- partial('header', {item: item}) %>
<div class='content'>
<ul class="list entry navigation">
<% (item.rows||[]).forEach(function(row){ %>
<% getList(item.rows).forEach(function(row){ %>
<li><a class="flat-box" title="<%- url_for(row.url) %>" href="<%- url_for(row.url) %>"
<% if (row.rel) { %>
rel="<%- row.rel %>"
Expand Down
4 changes: 2 additions & 2 deletions layout/_widget/load.ejs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<%
let widget_library_temp = [];
%>
<% (widgets||[]).forEach(function(widget){ %>
<% getList(widgets).forEach(function(widget){ %>
<% if (theme.sidebar.widget_library && (widget in theme.sidebar.widget_library)){ %>
<% let w = theme.sidebar.widget_library[widget]; w.id = widget; %>
<% if(w.sticky) { %>
Expand All @@ -22,7 +22,7 @@

<%
let widget_pjax_length = 0;
page.sidebar.forEach(function(e){
getList(page.sidebar).forEach(function(e){
if (e&&theme.sidebar.widget_library&&theme.sidebar.widget_library[e]) {
let widget_pjax_flag = theme.sidebar.widget_library[e].pjaxReload
let widget_stickys = theme.sidebar.widget_library[e].sticky
Expand Down
2 changes: 1 addition & 1 deletion layout/_widget/qrcode.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<section class="widget <%- item.class %> <%- page.widget_platform %> <%- page.widget_pjax %>">
<%- partial('header', {item: item}) %>
<div class='content article-entry'>
<% (item.images||[]).forEach(function(url){ %>
<% getList(item.images).forEach(function(url){ %>
<img src='<%- url_for(url) %>'
<% if (item.height) { %>
height='<%- item.height %>'
Expand Down
2 changes: 1 addition & 1 deletion layout/_widget/references.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ if (item.rows == undefined) {
var itms = new Array();
let id = item.id || 'references';
if (id in page) {
(page[id]||[]).forEach(function(ref) {
getList(page[id]).forEach(function(ref) {
if (ref.name || ref.url) {
item.rows.push(ref);
}
Expand Down
2 changes: 1 addition & 1 deletion layout/_widget/text.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<section class="widget <%- item.class %> <%- page.widget_platform %> <%- page.widget_pjax %>">
<%- partial('header', {item: item}) %>
<div class='content'>
<% (item.content||[]).forEach(function(row){ %>
<% getList(item.content).forEach(function(row){ %>
<%- markdown(row) %>
<% }) %>
</div>
Expand Down
2 changes: 1 addition & 1 deletion layout/archive.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<% if (post.icon) { %>
&nbsp;<i class="<%- post.icon %>" aria-hidden="true"></i>
<% } %>
<% (post.icons && post.icons||[]).forEach(function(icon){ %>
<% getList(post.icons).forEach(function(icon){ %>
&nbsp;<i class="<%- icon %>" aria-hidden="true"></i>
<% }) %>
</a>
Expand Down
8 changes: 4 additions & 4 deletions layout/friends.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<%- partial('_partial/meta',{post: page, position: 'top'}) %>
<%- page.excerpt %>
<% if (site.data.friends){ %>
<% site.data.friends.forEach((group, i) => { %>
<% getList(site.data.friends).forEach((group, i) => { %>
<div class='friends-group'>
<br>
<h2 class='friend-header'>
Expand All @@ -15,7 +15,7 @@
<%} %>
<% if (theme.pages.friends.layout_scheme == 'traditional') { %>
<div class='friend-content'>
<% (group.items||[]).forEach(function(item){ %>
<% getList(group.items).forEach(function(item){ %>
<% if (item.url && item.title) { %>
<a class='friend-card'
target="_blank" rel="external noopener noreferrer" href="<%- url_for(item.url || '/') %>">
Expand All @@ -28,7 +28,7 @@
<p class="friend-name"><%- item.title %></p>
<% if (item.keywords) { %>
<div class='friend-tags-wrapper'>
<% (item.keywords||[]).forEach(function(keyword){ %>
<% getList(item.keywords).forEach(function(keyword){ %>
<p class="tags"><i class="fa-solid fa-hashtag fa-fw" aria-hidden="true"></i><%= keyword %></p>
<% }) %>
</div>
Expand All @@ -45,7 +45,7 @@
</div>
<% } else { %>
<div class='simpleuser-group'>
<% (group.items||[]).forEach(function(item){ %>
<% getList(group.items).forEach(function(item){ %>
<% if (item.url && item.title) { %>
<a class="simpleuser" target="_blank" rel="external noopener noreferrer" href="<%- url_for(item.url || '/') %>">
<img src="<%- item.avatar || (theme.plugins.lazyload && theme.plugins.lazyload.loadingImg) %>"/>
Expand Down
4 changes: 2 additions & 2 deletions layout/layout.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<body itemscope itemtype="http://schema.org/WebPage">
<!-- import body_begin begin-->
<%_ if (config.import && config.import.body_begin){ _%>
<%_ ([...config.import.body_begin]).forEach(function(item){ _%>
<%_ getList(config.import.body_begin).forEach(function(item){ _%>
<%- item %>
<%_ }) _%>
<%_ } _%>
Expand Down Expand Up @@ -33,7 +33,7 @@
</div>
<!-- import body_end begin-->
<%_ if (config.import && config.import.body_end){ _%>
<%_ ([...config.import.body_end]).forEach(function(item){ _%>
<%_ getList(config.import.body_end).forEach(function(item){ _%>
<%- item %>
<%_ }) _%>
<%_ } _%>
Expand Down
11 changes: 11 additions & 0 deletions scripts/helpers/getList.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// yml string to list
// yml 太烂了

hexo.extend.helper.register('getList', function (list) {
if (!list) return []
if (typeof list == "string") {
return [list]
} else {
return [...list]
}
});

0 comments on commit 11ab545

Please sign in to comment.