Skip to content

Commit

Permalink
refactor: better usage of fragment_cache
Browse files Browse the repository at this point in the history
  • Loading branch information
SukkaW committed Oct 29, 2019
1 parent 3dc6862 commit ccfc8e2
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 23 deletions.
18 changes: 12 additions & 6 deletions layout/_partial/footer.ejs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<footer class="text-center">
<!-- footer copyright -->
<p class="footer-copyright mb-0">Copyright&nbsp;©&nbsp;<span id="copyright-year"></span>
<a class="footer-copyright-a" href="<%= config.url %>"><%= config.title %></a>
</p>
<%- fragment_cache('footer_copyright_text', () => {
return `
<p class="footer-copyright mb-0">Copyright&nbsp;©&nbsp;<span id="copyright-year"></span>
<a class="footer-copyright-a" href="${config.url}">${config.title}</a>
</p>`
}) %>

<!-- footer custom text -->
<p class="footer-text mb-0">
<%- fragment_cache('footer_custom_text', () => {
Expand All @@ -17,9 +21,11 @@
</p>
<!-- footer develop info -->
<p class="footer-develop mb-0">
<% if (theme.busuanzi.enable) { %>
<%- partial('_plugin/busuanzi/footer_counter', {}, {cache: theme.fragment_cache}) %>
<% } %>
<%- fragment_cache('footer_counter_text', () => {
if (theme.busuanzi.enable) return partial('_plugin/busuanzi/footer_counter');
return '';
}) %>

<% if ( (theme.valine_counter.enable) && (theme.valine_counter.site_pv.enable) ) { %>
<%- partial('_plugin/valine-counter/footer') %>
<% } %>
Expand Down
24 changes: 12 additions & 12 deletions layout/_partial/head/index.ejs
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
<head>
<meta charset="utf-8">
<!--
© SukkaW
hexo-theme-suka © SukkaW
GitHub: https://github.com/SukkaW/hexo-theme-suka
Version: <%= theme.verison %>
-->

<!-- ### Resource Hint ### -->

<!-- ## DNS Prefetch ## -->
<%- partial('_partial/head/dns-prefetch', {}, {cache: theme.fragment_cache}) %>
<!-- ## Preload ## -->
<%- partial('_partial/head/preload') %>
<%- partial('_partial/head/preload', {}, {cache: theme.fragment_cache}) %>

<!-- ### Meta & Title & Info ### -->
<meta http-equiv="X-UA-Compatible" content="IE=edge">
Expand Down Expand Up @@ -71,18 +70,19 @@
html += `<meta name="apple-mobile-web-app-title" content="${config.title}">`
html += '<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">'
/* PWA Manifest */
if (theme.head.pwa_manifest) {
html += `<link rel="manifest" href="${theme.head.pwa_manifest}">`
}
/* Open Search */
if (theme.head.open_search) {
html += `<link rel="search" type="application/opensearchdescription+xml" href="${theme.head.open_search}" title="${config.title}">`
}
return html;
}) %>

<!-- Manifest Import -->
<% if (theme.head.pwa_manifest) { %>
<link rel="manifest" href="<%= theme.head.pwa_manifest %>">
<% } %>
<!-- Open Search -->
<% if (theme.head.open_search) { %>
<link rel="search" type="application/opensearchdescription+xml" href="<%= theme.head.open_search %>" title="<%= config.title %>">
<% } %>

<!-- ### The Open Graph & Twitter Card Protocol ### -->
<%- _open_graph() %>

Expand Down
2 changes: 1 addition & 1 deletion layout/_partial/head/preload.ejs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% if(theme.busuanzi.enable) { %>
<% if (theme.busuanzi.enable) { %>
<!-- Busuanzi -->
<%- partial('_plugin/busuanzi/preload') %>
<% } %>
Expand Down
4 changes: 2 additions & 2 deletions layout/_partial/head/site-verification.ejs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<% if(theme.head.site_verification.google) { %>
<% if (theme.head.site_verification.google) { %>
<meta name="google-site-verification" content="<%= theme.head.site_verification.google %>" />
<% } %>
<% if(theme.head.site_verification.baidu) { %>
<% if (theme.head.site_verification.baidu) { %>
<meta name="baidu-site-verification" content="<%= theme.head.site_verification.baidu %>" />
<% } %>
2 changes: 1 addition & 1 deletion layout/_partial/header.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
<% } %>
</p>

<%- partial('_partial/index-nav', {}, {cache: theme.fragment_cache}) %>
<%- partial('_partial/index-nav') %>
</header>
2 changes: 1 addition & 1 deletion layout/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<!-- # Post List # -->
<% page.posts.each(function(post) { %>
<% if(!((typeof hasposttop === 'function') && post.top)) { %>
<%- partial('_partial/post-entry', { post: post, index: true, pin: false }) %>
<%- partial('_partial/post-entry', { post, index: true, pin: false }) %>
<% } %>
<% }); %>
</div>
Expand Down

0 comments on commit ccfc8e2

Please sign in to comment.