Skip to content

Commit

Permalink
fix: ejs
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaoo committed Nov 21, 2020
1 parent 5cb6e6f commit e9e509c
Show file tree
Hide file tree
Showing 24 changed files with 168 additions and 100 deletions.
2 changes: 1 addition & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ preview:
api: https://v1.hitokoto.cn/?encode=text&c=d

# Copyright
copyright: <p>Powered by <a target="_blank" href="https://hexo.io">Hexo</a> | Theme - <a target="_blank" href="https://github.com/izhaoo/hexo-theme-zhaoo">zhaoo</a></p>
# copyright: <p>Powered by <a target="_blank" href="https://hexo.io">Hexo</a> | Theme - <a target="_blank" href="https://github.com/izhaoo/hexo-theme-zhaoo">zhaoo</a></p>

# Social
social:
Expand Down
2 changes: 1 addition & 1 deletion layout/_partial/components/fab.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</div>
<% } %>
<% if (theme.tencentChao.enable) { %>
<a href="https://support.qq.com/product/<%- theme.tencentChao.appId %>" target="_blank">
<a href="https://support.qq.com/product/<%= theme.tencentChao.appId %>" target="_blank">
<div class="fab fab-tencent-chao">
<i class="iconfont iconcomment"></i>
</div>
Expand Down
15 changes: 9 additions & 6 deletions layout/_partial/components/footer.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,22 @@
var arr = theme.social[i].split('||');
var url = arr[0];
var iconfont = arr[1];
var color = arr[2] || "'"+theme.color.link+"'";
var color = arr[2] || theme.color.link;
socialList +=
`<a
href="${url}"
target="_blank"
href="${url}"
target="_blank"
class="footer-social-item"
onMouseOver="this.style.color=${color}"
onMouseOut="this.style.color='${theme.color.default}'">
<i class="iconfont footer-social-item ${iconfont}"></i>
onMouseOut="this.style.color='${theme.color.text}'">
<i class="iconfont ${iconfont}"></i>
</a>`;
}
%>

<footer class="footer">
<div class="footer-social"><%- socialList %></div>
<%- theme.copyright && `<div class="footer-copyright">${theme.copyright}</div>` %>
<% if (theme.copyright) { %>
<div class="footer-copyright"><%- theme.copyright %></div>
<% } %>
</footer>
4 changes: 2 additions & 2 deletions layout/_partial/components/header.ejs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<header class="header">
<h1 class="header-title"><%- title %></h1>
<p class="header-subtitle"><%- subtitle %></p>
<h1 class="header-title"><%= title %></h1>
<p class="header-subtitle"><%= subtitle %></p>
</header>
4 changes: 3 additions & 1 deletion layout/_partial/components/menu.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
<i class="iconfont iconbaseline-close-px"></i>
</div>
<ul class="menu-content"><%- menuList %></ul>
<%- theme.copyright && `<div class="menu-copyright">${theme.copyright}</div>` %>
<% if (theme.copyright) { %>
<div class="menu-copyright"><%- theme.copyright %></div>
<% } %>
</div>
</nav>
14 changes: 10 additions & 4 deletions layout/_partial/components/navbar.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,19 @@
<% if (title) { %>
<nav class="navbar">
<div class="left">
<%- theme.qrcode.enable && `<i class="iconfont iconqrcode j-navbar-qrcode"></i>` %>
<%- theme.color_mode.enable && `<i class="iconfont iconmoono" id="color-toggle" color-toggle="light"></i>` %>
<% if (theme.qrcode.enable) { %>
<i class="iconfont iconqrcode j-navbar-qrcode"></i>
<% } %>
<% if (theme.color_mode.enable) { %>
<i class="iconfont iconmoono" id="color-toggle" color-toggle="light"></i>
<% } %>
</div>
<div class="center"><%- title %></div>
<div class="center"><%= title %></div>
<div class="right">
<i class="iconfont iconmenu j-navbar-menu"></i>
</div>
<%- theme.qrcode.enable && `<div id="qrcode-navbar"></div>` %>
<% if (theme.qrcode.enable) { %>
<div id="qrcode-navbar"></div>
<% } %>
</nav>
<% } %>
45 changes: 29 additions & 16 deletions layout/_partial/head.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ var description = '';
%>

<!DOCTYPE html>
<html lang="<%= config.language %>" <%= theme.color_mode.enable && `color-mode=light` %>>

<html lang="<%= config.language %>" <%- theme.color_mode.enable ? `color-mode=light` : `` %>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
Expand All @@ -29,20 +28,28 @@ var description = '';
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="google" content="notranslate" />
<%- keywords && `<meta name="keywords" content="${keywords}">` %>
<%- description && `<meta name="description" content="${description}">` %>
<%- config.author && `<meta name="author" content="${config.author}">` %>
<%- theme.favicon.small && `<link rel="icon" href="${theme.favicon.small}" type="image/png" sizes="16x16">` %>
<%- theme.favicon.medium && `<link rel="icon" href="${theme.favicon.medium}" type="image/png" sizes="32x32">` %>
<%- theme.favicon.apple_touch_icon && `<link rel="apple-touch-icon" href="${theme.favicon.apple_touch_icon}" sizes="180x180">` %>
<%- theme.favicon.safari_pinned_tab && `<meta rel="mask-icon" href="${theme.favicon.safari_pinned_tab}" color="#333333">` %>
<%- theme.favicon.msapplication && `<meta rel="msapplication-TileImage" content="${theme.favicon.msapplication}">
<meta rel="msapplication-TileColor" content="#000000">`%>
<%- keywords ? `<meta name="keywords" content="${keywords}">` : `` %>
<%- description ? `<meta name="description" content="${description}">` : `` %>
<%- config.author ? `<meta name="author" content="${config.author}">` : `` %>
<%- theme.favicon.small ? `<link rel="icon" href="${theme.favicon.small}" type="image/png" sizes="16x16">` : `` %>
<%- theme.favicon.medium ? `<link rel="icon" href="${theme.favicon.medium}" type="image/png" sizes="32x32">` : `` %>
<%- theme.favicon.apple_touch_icon ? `<link rel="apple-touch-icon" href="${theme.favicon.apple_touch_icon}" sizes="180x180">` : `` %>
<%- theme.favicon.safari_pinned_tab ? `<meta rel="mask-icon" href="${theme.favicon.safari_pinned_tab}" color="#333333">` : `` %>
<% if (theme.favicon.msapplication) { %>
<meta rel="msapplication-TileImage" content="<%- theme.favicon.msapplication %>">
<meta rel="msapplication-TileColor" content="#000000">
<% } %>

<%- css(['css/style']) %>
<%- theme.vendors.iconfont_css && css(theme.vendors.iconfont_css) %>
<%- theme.fancybox && (theme.vendors.fancybox_css ? css(theme.vendors.fancybox_css) : css('lib/fancybox/fancybox.css')) %>


<% if (theme.vendors.iconfont_css) { %>
<%- css(theme.vendors.iconfont_css) %>
<% } %>

<% if (theme.fancybox) { %>
<%- theme.vendors.fancybox_css ? css(theme.vendors.fancybox_css) : css('lib/fancybox/fancybox.css') %>
<% } %>

<% if(theme.highlight.enable){ %>
<% if(theme.vendors.highlight_css){ %>
<% for (i in theme.highlight.style) { %>
Expand Down Expand Up @@ -104,6 +111,12 @@ var description = '';
}
</script>

<%- theme.custom.head && theme.custom.head %>
<%- theme.custom.css && css(theme.custom.css) %>
<% if (theme.custom.head) { %>
<%- theme.custom.head %>
<% } %>

<% if (theme.custom.css) { %>
<%- css(theme.custom.css) %>
<% } %>

</head>
12 changes: 7 additions & 5 deletions layout/_partial/index/item.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,27 @@

<div class="col-lg-4 col-md-6 col-sm-12 post-item">
<div class="post-wrap">
<%- post.top && `<div class="post-top"><div>置顶</div></div>` %>
<% if (post.top) { %>
<div class="post-top"><div>置顶</div></div>
<% } %>
<a href="<%- url_for(post.path) %>" class="post-image">
<%- image_tag(post_image(post.image), { draggable: "false" }) %>
</a>
<div class="post-content">
<div class="post-content-wrap">
<h3 class="post-title"><a href="<%- url_for(post.path) %>" title="<%= post.title %>" ><%= post.title %></a></h3>
<div class="post-excerpt">
<p class="substr-3"><%- excerpt %></p>
<p class="substr-3"><%= excerpt %></p>
</div>
</div>
<div class="post-info">
<span class="post-info-item"><i class="iconfont iconcalendar"></i><%- date(post.date, "MMMM DD, YYYY") %></span>
<% if(theme.leancloud.enable) { %>
<span class="post-info-item"><i class="iconfont iconcalendar"></i><%= date(post.date, "MMMM DD, YYYY") %></span>
<% if (theme.leancloud.enable) { %>
<span class="post-info-item">
<i class="iconfont iconeye"></i><span id="<%= url_for(post.path) %>" class="leancloud" data-flag-title="<%- post.title %>"></span>
</span>
<% } %>
<span class="post-info-item"><i class="iconfont iconfont-size"></i><%- strip_html(post.content).length %></span>
<span class="post-info-item"><i class="iconfont iconfont-size"></i><%= strip_html(post.content).length %></span>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion layout/_partial/index/preview.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<i class="iconfont iconmenu"></i>
</nav>
<div class="preview-image">
<h2 class="preview-motto" id="motto"><%- theme.preview.motto.default %></h2>
<h2 class="preview-motto" id="motto"><%= theme.preview.motto.default %></h2>
<!-- <span class="preview-cursor">|</span> -->
<% if (theme.preview.model === 'cloud') { %>
<%- image_tag("/images/theme/cloud.png", {class: "preview-overlay", draggable:"false"}) %>
Expand Down
10 changes: 7 additions & 3 deletions layout/_partial/plugins/analytics.ejs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<%- theme.analytics.baidu && `<script defer src='https://hm.baidu.com/hm.js?${theme.analytics.baidu}'></script>` %>
<% if (theme.analytics.baidu) { %>
<script defer src='https://hm.baidu.com/hm.js?<%- theme.analytics.baidu %>'></script>
<% } %>

<%- theme.analytics.cnzz && `<script defer src='https://s9.cnzz.com/z_stat.php?id=${theme.analytics.cnzz}&web_id=${theme.analytics.cnzz}'></script>` %>
<% if (theme.analytics.cnzz) { %>
<script defer src='https://s9.cnzz.com/z_stat.php?id=<%- theme.analytics.cnzz %>&web_id=<%- theme.analytics.cnzz %>'></script>
<% } %>

<% if (theme.analytics.google) { %>
<script>
Expand All @@ -14,7 +18,7 @@
<script async src='https://www.google-analytics.com/analytics.js'></script>
<% } %>

<% if(theme.analytics.tencent) { %>
<% if (theme.analytics.tencent) { %>
<script>
var _mtac = {};
(function () {
Expand Down
2 changes: 1 addition & 1 deletion layout/_partial/plugins/seo.ejs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% if(theme.seo.baidu_auto_push) { %>
<% if (theme.seo.baidu_auto_push) { %>
<script>
(function () {
var bp = document.createElement('script');
Expand Down
12 changes: 9 additions & 3 deletions layout/_partial/post/article.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@
<%- page.more %>
</section>
<section class="extra">
<%- (theme.post_copyright.enable && page.copyright !== false) && partial('_partial/post/copyright') %>
<%- theme.donate.enable && partial('_partial/post/donate') %>
<% if (theme.post_copyright.enable && page.copyright !== false) { %>
<%- partial('_partial/post/copyright') %>
<% } %>
<% if (theme.donate.enable) { %>
<%- partial('_partial/post/donate') %>
<% } %>
<%- partial('_partial/post/tag') %>
<%- partial('_partial/post/nav') %>
</section>
<%- theme.comments.enable && partial('_partial/post/comments') %>
<% if (theme.comments.enable) { %>
<%- partial('_partial/post/comments') %>
<% } %>
</section>
</div>
</article>
4 changes: 3 additions & 1 deletion layout/_partial/post/comments.ejs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<section class="comments">
<%- theme.comments.button && `<div class="btn" id="comments-btn">查看评论</div>` %>
<% if (theme.comments.button) { %>
<div class="btn" id="comments-btn">查看评论</div>
<% } %>
<%- partial('_partial/comments/' + theme.comments.type) %>
</section>
7 changes: 3 additions & 4 deletions layout/_partial/post/copyright.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
<li><strong>版权声明:</strong>本文作者放弃了版权,大家随意搬运,特此奉上搬运链接:<a href="javascript:;" class="j-carrier-btn">一键打包带走</a></li>
<input value="<%= carrier(); %>" class="j-carrier-data carrier-data">
<% } else { %>
<li><strong>本文作者:</strong><%- config.author %></li>
<li><strong>本文链接:</strong><a href="<%- url %>"><%- url %></a></li>
<li><strong>版权声明:</strong>本博客所有文章均采用<a href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh"
rel="external nofollow" target="_blank"> BY-NC-SA </a>许可协议,转载请注明出处!</li>
<li><strong>本文作者:</strong><%= config.author %></li>
<li><strong>本文链接:</strong><%- link_to(full_url_for(url), full_url_for(url)) %></li>
<li><strong>版权声明:</strong>本博客所有文章均采用 <%- link_to('https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh', 'BY-NC-SA', {external: true}) %> 许可协议,转载请注明出处!</li>
<% } %>
</ul>
8 changes: 4 additions & 4 deletions layout/_partial/post/head.ejs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<section class="head">
<%- image_tag(post_image(page.image), { draggable: "false" }) %>
<div class="head-mask">
<h1 class="head-title"><%- page.title %></h1>
<h1 class="head-title"><%= page.title %></h1>
<div class="head-info">
<span class="post-info-item"><i class="iconfont iconcalendar"></i><%- date(page.date, "MMMM DD, YYYY") %></span>
<% if(theme.leancloud.enable) { %>
<span class="post-info-item"><i class="iconfont iconcalendar"></i><%= date(page.date, "MMMM DD, YYYY") %></span>
<% if (theme.leancloud.enable) { %>
<span class="post-info-item">
<i class="iconfont iconeye"></i><span id="<%- url_for(page.path) %>" class="leancloud" data-flag-title="<%- page.title %>"></span>
</span>
<% } %>
<span class="post-info-item"><i class="iconfont iconfont-size"></i><%- strip_html(page.content).length %></span>
<span class="post-info-item"><i class="iconfont iconfont-size"></i><%= strip_html(page.content).length %></span>
</div>
</div>
</section>
6 changes: 3 additions & 3 deletions layout/_partial/post/nav.ejs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<% if (page.prev || page.next){ %>
<% if (page.prev || page.next) { %>
<nav class="nav">
<%- page.prev && `<a href="${url_for(page.prev.path)}"><i class="iconfont iconleft"></i>${page.prev.title}</a>` %>
<%- page.next && `<a href="${url_for(page.next.path)}">${page.next.title}<i class="iconfont iconright"></i></a>` %>
<%- page.prev ? `<a href="${url_for(page.prev.path)}"><i class="iconfont iconleft"></i>${page.prev.title}</a>` : `<a></a>` %>
<%- page.next ? `<a href="${url_for(page.next.path)}">${page.next.title}<i class="iconfont iconright"></i></a>` : `<a></a>` %>
</nav>
<% } %>
38 changes: 31 additions & 7 deletions layout/_partial/script.ejs
Original file line number Diff line number Diff line change
@@ -1,11 +1,35 @@
<%- theme.vendors.jquery_js ? js(theme.vendors.jquery_js) : js('lib/jquery/jquery.js') %>
<%- theme.lazyload && (theme.vendors.lazyload_js ? js(theme.vendors.lazyload_js) : js('lib/lazyload/lazyload.js')) %>
<%- theme.fancybox && (theme.vendors.fancybox_js ? js(theme.vendors.fancybox_js) : js('lib/fancybox/fancybox.js'))%>
<%- theme.pjax && (theme.vendors.pjax_js ? js(theme.vendors.pjax_js) : js('lib/pjax/pjax.js')) %>
<%- theme.qrcode.enable && (theme.vendors.qrcode_js ? js(theme.vendors.qrcode_js) : js('lib/qrcode/qrcode.js')) %>

<% if (theme.lazyload) { %>
<%- theme.vendors.lazyload_js ? js(theme.vendors.lazyload_js) : js('lib/lazyload/lazyload.js') %>
<% } %>

<% if (theme.fancybox) { %>
<%- theme.vendors.fancybox_js ? js(theme.vendors.fancybox_js) : js('lib/fancybox/fancybox.js') %>
<% } %>

<% if (theme.pjax) { %>
<%- theme.vendors.pjax_js ? js(theme.vendors.pjax_js) : js('lib/pjax/pjax.js') %>
<% } %>

<% if (theme.qrcode.enable) { %>
<%- theme.vendors.qrcode_js ? js(theme.vendors.qrcode_js) : js('lib/qrcode/qrcode.js') %>
<% } %>

<%- js(['js/utils', 'js/script']) %>
<%- theme.leancloud.enable && partial('_partial/plugins/visitors') %>

<% if (theme.leancloud.enable) { %>
<%- partial('_partial/plugins/visitors') %>
<% } %>

<%- partial('_partial/plugins/seo') %>

<%- partial('_partial/plugins/analytics') %>
<%- theme.custom.foot && theme.custom.foot %>
<%- theme.custom.js && js(theme.custom.js) %>

<% if (theme.custom.foot) { %>
<%- theme.custom.foot %>
<% } %>

<% if (theme.custom.js) { %>
<%- js(theme.custom.js) %>
<% } %>
12 changes: 6 additions & 6 deletions layout/archive.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
<div class="archive-post">
<h3 class="archive-total">归档: <%= site.posts.length %> 篇</h3>
<% var posts = site.posts.sort('date', 'desc'); %>
<% for(var i = 0, year = -1; i < posts.data.length; ++i) { %>
<% for (var i = 0, year = -1; i < posts.data.length; ++i) { %>
<%
var post = posts.data[i];
if (post.date.year() !== year) {
var year = post.date.year();
}
year = post.date.year();
%>
<h3 class="archive-year"><%- year %></h3>
<h3 class="archive-year"><%= year %></h3>
<% } %>
<div class="archive-item">
<a class="archive-date" href="<%- url_for(post.path) %>"><%- date(post.date, "MMMM DD") %></a>
<a class="archive-title" href="<%- url_for(post.path) %>"><%- post.title %></a>
<a class="archive-date" href="<%- url_for(post.path) %>"><%= date(post.date, "MMMM DD") %></a>
<a class="archive-title" href="<%- url_for(post.path) %>"><%= post.title %></a>
</div>
<% } %>
</div>
Expand Down
Loading

0 comments on commit e9e509c

Please sign in to comment.