Skip to content

Commit

Permalink
Cache is not enough? Ok, let's cache sidebar, scripts and 3rd-party's.
Browse files Browse the repository at this point in the history
Issues: #539, #385.
  • Loading branch information
ivan-nginx committed Dec 28, 2018
1 parent 24776f5 commit bb5cfe6
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 39 deletions.
41 changes: 21 additions & 20 deletions layout/_layout.swig
Original file line number Diff line number Diff line change
Expand Up @@ -94,30 +94,31 @@
{% endif %}
</div>

{% include '_scripts/vendors.swig' %}
{% include '_scripts/commons.swig' %}
{{ partial('_scripts/vendors.swig', {}, {cache: theme.cache.enable}) }}
{{ partial('_scripts/commons.swig', {}, {cache: theme.cache.enable}) }}

{% set scheme_script = '_scripts/schemes/' + theme.scheme | lower + '.swig' %}
{% include scheme_script %}
{{ partial(scheme_script, {}, {cache: theme.cache.enable}) }}

{% block script_extra %}{% endblock %}

{% include '_scripts/boostrap.swig' %}

{% include '_third-party/comments/index.swig' %}
{% include '_third-party/search/index.swig' %}
{% include '_third-party/analytics/lean-analytics.swig' %}
{% include '_third-party/analytics/firestore.swig' %}
{% include '_third-party/seo/baidu-push.swig' %}
{% include '_third-party/schedule.swig' %}
{% include '_third-party/math/index.swig' %}
{% include '_third-party/needsharebutton.swig' %}
{% include '_third-party/rating.swig' %}
{% include '_third-party/pangu.swig' %}
{% include '_third-party/scroll-cookie.swig' %}
{% include '_third-party/exturl.swig' %}
{% include '_third-party/bookmark.swig' %}
{% include '_third-party/copy-code.swig' %}
{% include '_third-party/pdf.swig' %}
{{ partial('_scripts/boostrap.swig', {}, {cache: theme.cache.enable}) }}

{{ partial('_third-party/comments/index.swig', {}, {cache: theme.cache.enable}) }}
{{ partial('_third-party/search/index.swig', {}, {cache: theme.cache.enable}) }}
{{ partial('_third-party/analytics/lean-analytics.swig', {}, {cache: theme.cache.enable}) }}
{{ partial('_third-party/analytics/firestore.swig', {}, {cache: theme.cache.enable}) }}
{{ partial('_third-party/seo/baidu-push.swig', {}, {cache: theme.cache.enable}) }}
{{ partial('_third-party/schedule.swig', {}, {cache: theme.cache.enable}) }}
{{ partial('_third-party/math/index.swig', {}, {cache: theme.cache.enable}) }}
{{ partial('_third-party/needsharebutton.swig', {}, {cache: theme.cache.enable}) }}
{{ partial('_third-party/rating.swig', {}, {cache: theme.cache.enable}) }}
{{ partial('_third-party/pangu.swig', {}, {cache: theme.cache.enable}) }}
{{ partial('_third-party/scroll-cookie.swig', {}, {cache: theme.cache.enable}) }}
{{ partial('_third-party/exturl.swig', {}, {cache: theme.cache.enable}) }}
{{ partial('_third-party/bookmark.swig', {}, {cache: theme.cache.enable}) }}
{{ partial('_third-party/copy-code.swig', {}, {cache: theme.cache.enable}) }}
{{ partial('_third-party/pdf.swig', {}, {cache: theme.cache.enable}) }}

</body>
</html>
5 changes: 2 additions & 3 deletions layout/_macro/sidebar.swig → layout/_partials/sidebar.swig
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{% macro render(is_post) %}
<div class="sidebar-toggle">
<div class="sidebar-toggle-line-wrap">
<span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
Expand All @@ -13,7 +12,7 @@
{% endif %}
<div class="sidebar-inner">

{% set display_toc = is_post and theme.toc.enable or is_page and theme.toc.enable %}
{% set display_toc = is_post and theme.toc.enable %}

{% if display_toc and toc(page.content).length > 1 %}
<ul class="sidebar-nav motion-element">
Expand Down Expand Up @@ -84,6 +83,7 @@
{% if hasTagsPage %}</a>{% endif %}
</div>
{% endif %}

</nav>
{% endif %}

Expand Down Expand Up @@ -186,4 +186,3 @@

</div>
</aside>
{% endmacro %}
3 changes: 1 addition & 2 deletions layout/archive.swig
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{% extends '_layout.swig' %}
{% import '_macro/post-collapse.swig' as post_template %}
{% import '_macro/sidebar.swig' as sidebar_template %}

{% block title %}{{ __('title.archive') }} | {{ title }}{% endblock %}

Expand Down Expand Up @@ -60,5 +59,5 @@
{% endblock %}

{% block sidebar %}
{{ sidebar_template.render(false) }}
{{ partial('_partials/sidebar.swig', {}, {cache: theme.cache.enable}) }}
{% endblock %}
3 changes: 1 addition & 2 deletions layout/category.swig
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{% extends '_layout.swig' %}
{% import '_macro/post-collapse.swig' as post_template %}
{% import '_macro/sidebar.swig' as sidebar_template %}

{% block title %}{{ __('title.category') }}: {{ page.category }} | {{ title }}{% endblock %}

Expand Down Expand Up @@ -34,5 +33,5 @@
{% endblock %}

{% block sidebar %}
{{ sidebar_template.render(false) }}
{{ partial('_partials/sidebar.swig', {}, {cache: theme.cache.enable}) }}
{% endblock %}
3 changes: 1 addition & 2 deletions layout/index.swig
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{% extends '_layout.swig' %}
{% import '_macro/post.swig' as post_template %}
{% import '_macro/sidebar.swig' as sidebar_template %}

{% block title %}{{ title }}{% if theme.index_with_subtitle and subtitle %} – {{ subtitle }}{% endif %}{% endblock %}

Expand All @@ -19,5 +18,5 @@
{% endblock %}

{% block sidebar %}
{{ sidebar_template.render(false) }}
{{ partial('_partials/sidebar.swig', {}, {cache: theme.cache.enable}) }}
{% endblock %}
3 changes: 1 addition & 2 deletions layout/page.swig
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{% extends '_layout.swig' %}
{% import '_macro/sidebar.swig' as sidebar_template %}

{% block title %}{#
#}{% set page_title_suffix = ' | ' + title %}{#
Expand Down Expand Up @@ -79,7 +78,7 @@
{% endblock %}

{% block sidebar %}
{{ sidebar_template.render(false) }}
{{ partial('_partials/sidebar.swig', {}, {cache: theme.cache.enable}) }}
{% endblock %}

{% block script_extra %}
Expand Down
7 changes: 1 addition & 6 deletions layout/post.swig
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
{% extends '_layout.swig' %}
{% import '_macro/post.swig' as post_template %}
{% import '_macro/sidebar.swig' as sidebar_template %}


{% block title %}{{ page.title }} | {{ title }}{% endblock %}

{% block page_class %}page-post-detail{% endblock %}


{% block content %}

<div id="posts" class="posts-expand">
{{ post_template.render(page) }}
</div>

{% endblock %}

{% block sidebar %}
{{ sidebar_template.render(true) }}
{{ partial('_partials/sidebar.swig', {}, {cache: theme.cache.enable}) }}
{% endblock %}

{% block script_extra %}
Expand Down
3 changes: 1 addition & 2 deletions layout/tag.swig
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{% extends '_layout.swig' %}
{% import '_macro/post-collapse.swig' as post_template %}
{% import '_macro/sidebar.swig' as sidebar_template %}

{% block title %}{{ __('title.tag') }}: {{ page.tag }} | {{ title }}{% endblock %}

Expand Down Expand Up @@ -33,5 +32,5 @@
{% endblock %}

{% block sidebar %}
{{ sidebar_template.render(false) }}
{{ partial('_partials/sidebar.swig', {}, {cache: theme.cache.enable}) }}
{% endblock %}

0 comments on commit bb5cfe6

Please sign in to comment.