diff --git a/_config.yml b/_config.yml index 6c0896583b4..79f153d5603 100644 --- a/_config.yml +++ b/_config.yml @@ -58,7 +58,7 @@ analytics: # Pageviews settings pageviews: - provider: # [google | goatcounter] + provider: # now only supports 'goatcounter' # Prefer color scheme setting. # diff --git a/_includes/analytics/goatcounter.html b/_includes/analytics/goatcounter.html index c7fef85e005..78c90b72682 100644 --- a/_includes/analytics/goatcounter.html +++ b/_includes/analytics/goatcounter.html @@ -1,7 +1,6 @@ - diff --git a/_includes/analytics/google.html b/_includes/analytics/google.html index b6e09d2a575..d0aac651c22 100644 --- a/_includes/analytics/google.html +++ b/_includes/analytics/google.html @@ -1,4 +1,3 @@ - {% endif %} + {% if page.layout == 'post' %} - - {% if site.pageviews.provider != empty and site.pageviews.provider %} - {% case site.pageviews.provider %} + {% assign provider = site.pageviews.provider %} + + {% if provider and provider != empty %} + {% case provider %} {% when 'goatcounter' %} - {% if site.analytics.goatcounter.id != empty and site.analytics.goatcounter.id %} - {% include views-counter/goatcounter.html %} + {% if site.analytics[provider].id != empty and site.analytics[provider].id %} + {% include pageviews/{{ provider }}.html %} {% endif %} {% endcase %} {% endif %} @@ -113,13 +115,12 @@ {% endif %} - - {% if site.analytics.google.id != empty and site.analytics.google.id %} - {% include analytics/google.html %} - {% endif %} - - - {% if site.analytics.goatcounter.id != empty and site.analytics.goatcounter.id %} - {% include analytics/goatcounter.html %} - {% endif %} + + {% for analytics in site.analytics %} + {% capture str %}{{ analytics }}{% endcapture %} + {% assign type = str | split: '{' | first %} + {% if site.analytics[type].id and site.analytics[type].id != empty %} + {% include analytics/{{ type }}.html %} + {% endif %} + {% endfor %} {% endif %} diff --git a/_includes/pageviews/goatcounter.html b/_includes/pageviews/goatcounter.html new file mode 100644 index 00000000000..af536dbdd7c --- /dev/null +++ b/_includes/pageviews/goatcounter.html @@ -0,0 +1,18 @@ + + diff --git a/_includes/views-counter.html b/_includes/views-counter.html deleted file mode 100644 index c8c2d36283e..00000000000 --- a/_includes/views-counter.html +++ /dev/null @@ -1,11 +0,0 @@ - -{% if site.pageviews.provider != empty - and site.pageviews.provider - and site.analytics.goatcounter.id != empty - and site.analytics.goatcounter.id -%} - - 1 - {{ site.data.locales[lang].post.pageview_measure }} - -{% endif %} diff --git a/_includes/views-counter/goatcounter.html b/_includes/views-counter/goatcounter.html deleted file mode 100644 index dfcfee2a2da..00000000000 --- a/_includes/views-counter/goatcounter.html +++ /dev/null @@ -1,12 +0,0 @@ - diff --git a/_layouts/post.html b/_layouts/post.html index 521582e25aa..f666d71642c 100644 --- a/_layouts/post.html +++ b/_layouts/post.html @@ -8,6 +8,7 @@ - post-nav - comments --- + {% include lang.html %}
@@ -74,16 +75,21 @@

{{ page.title }}

- - {% include views-counter.html %} + + {% if site.pageviews.provider and site.analytics[site.pageviews.provider].id %} + + + + + {{ site.data.locales[lang].post.pageview_measure }} + + {% endif %} {% include read-time.html content=content prompt=true lang=lang %}
- -