Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: better usage of fragment_cache #152

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 35 additions & 28 deletions layout/_partial/after-footer.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,41 @@
</script>
<% } %>

<%- js('js/jquery-3.4.1.min.js') %>
<%- fragment_cache('after_footer_custom', () => {
let html = ''
html += js('js/jquery-3.4.1.min.js');
if (theme.fancybox) {
html += js('fancybox/jquery.fancybox.min.js')
}

<% if (theme.fancybox){ %>
<%- js('fancybox/jquery.fancybox.min.js') %>
<% } %>
html += js('js/script');
html += partial('gauges-analytics')

<%- js('js/script') %>
<%- partial('gauges-analytics') %>
if (theme.valine.enable && theme.valine.appId && theme.valine.appKey) {
html += js('https://cdn.jsdelivr.net/npm/valine@1.3.10/dist/Valine.min.js');

<% if(theme.valine.enable && theme.valine.appId && theme.valine.appKey){ %>
<%- js('https://cdn.jsdelivr.net/npm/valine@1.3.10/dist/Valine.min.js') %>
<script>
var GUEST_INFO = ['nick','mail','link'];
var guest_info = '<%= theme.valine.guest_info %>'.split(',').filter(function(item){
return GUEST_INFO.indexOf(item) > -1
});
var notify = '<%= theme.valine.notify %>' == true;
var verify = '<%= theme.valine.verify %>' == true;
new Valine({
el: '.vcomment',
notify: notify,
verify: verify,
appId: "<%= theme.valine.appId %>",
appKey: "<%= theme.valine.appKey %>",
placeholder: "<%= theme.valine.placeholder %>",
pageSize:'<%= theme.valine.pageSize %>',
avatar:'<%= theme.valine.avatar %>',
lang:'<%= theme.valine.lang %>'
});
</script>
<% } %>
html += `
<script>
var GUEST_INFO = ['nick','mail','link'];
var guest_info = '${theme.valine.guest_info}'.split(',').filter(function(item){
return GUEST_INFO.indexOf(item) > -1
});
var notify = '${theme.valine.notify}' == true;
var verify = '${theme.valine.verify}' == true;
new Valine({
el: '.vcomment',
notify: notify,
verify: verify,
appId: "${theme.valine.appId}",
appKey: "${theme.valine.appKey}",
placeholder: "${theme.valine.placeholder}",
pageSize:'${theme.valine.pageSize}',
avatar:'${theme.valine.avatar}',
lang:'${theme.valine.lang}'
});
</script>
`
}

return html
}) %>
13 changes: 11 additions & 2 deletions layout/layout.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,18 @@
<%- partial('_partial/header', null, {cache: !config.relative_link}) %>
<div class="outer">
<section id="main"><%- body %></section>
<% if (theme.sidebar && theme.sidebar !== 'bottom'){ %>
<%- partial('_partial/sidebar', null, {cache: !config.relative_link}) %>

<% if (!config.relative_link) { %>
<%- fragment_cache('sidebar', function() {
if (theme.sidebar && theme.sidebar !== 'bottom') return partial('_partial/sidebar');
return '';
}) %>
<% } else { %>
<% if (theme.sidebar && theme.sidebar !== 'bottom') { %>
<%- partial('_partial/sidebar') %>
<% } %>
<% } %>

</div>
<%- partial('_partial/footer', null, {cache: !config.relative_link}) %>
</div>
Expand Down