From e87ef0d40e5733c7bce0a0b9e7cae8a8550652c7 Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Tue, 23 Jun 2020 13:10:28 +0800 Subject: [PATCH] Fixed the PV cache. --- _includes/js-selector.html | 8 ++++++++ assets/js/_home-post.js | 2 +- assets/js/data/cache-list.js | 2 +- assets/js/data/pv-cache.js | 11 +++++++++++ assets/js/data/pv-data.js | 9 --------- 5 files changed, 21 insertions(+), 11 deletions(-) create mode 100644 assets/js/data/pv-cache.js delete mode 100644 assets/js/data/pv-data.js diff --git a/_includes/js-selector.html b/_includes/js-selector.html index e77930e..3f8a873 100644 --- a/_includes/js-selector.html +++ b/_includes/js-selector.html @@ -8,10 +8,18 @@ {% if page.layout == 'home' %} + {% if site.google_analytics.pv.cache and site.google_analytics.pv.enabled %} + + {% endif %} + {% elsif page.layout == 'post' %} + {% if site.google_analytics.pv.cache and site.google_analytics.pv.enabled %} + + {% endif %} + {% if page.math %} diff --git a/assets/js/_home-post.js b/assets/js/_home-post.js index afc128b..48f5dc4 100644 --- a/assets/js/_home-post.js +++ b/assets/js/_home-post.js @@ -13,7 +13,7 @@ {% if site.google_analytics.pv.enabled %} - {% include_relative data/pv-data.js %} + const proxyData = '{"url": "{{ site.google_analytics.pv.proxy_endpoint }}"}'; {% include_relative _utils/pageviews.js %} diff --git a/assets/js/data/cache-list.js b/assets/js/data/cache-list.js index 65966bb..31db1b8 100644 --- a/assets/js/data/cache-list.js +++ b/assets/js/data/cache-list.js @@ -106,6 +106,6 @@ const include = [ ]; const exclude = [ - '/assets/js/data/pv-data.js', + '/assets/js/data/pv-cache.js', '/img.shields.io/' ]; diff --git a/assets/js/data/pv-cache.js b/assets/js/data/pv-cache.js new file mode 100644 index 0000000..2e309bf --- /dev/null +++ b/assets/js/data/pv-cache.js @@ -0,0 +1,11 @@ +--- +layout: compress +--- + +{%- capture pv_data -%} + {%- if site.google_analytics.pv.cache and site.google_analytics.pv.enabled -%} + {% include_relative _pageviews.json %} + {%- endif -%} +{%- endcapture -%} + +const pageviews = '{{ pv_data }}'; diff --git a/assets/js/data/pv-data.js b/assets/js/data/pv-data.js deleted file mode 100644 index eaceee8..0000000 --- a/assets/js/data/pv-data.js +++ /dev/null @@ -1,9 +0,0 @@ -const proxyData = '{"url": "{{ site.google_analytics.pv.proxy_endpoint }}"}'; - -{%- capture pv_data -%} - {%- if site.google_analytics.pv.cache and site.google_analytics.pv.enabled -%} - {% include_relative data/_pageviews.json %} - {%- endif -%} -{%- endcapture -%} - -const pageviews = '{{ pv_data }}'; \ No newline at end of file