diff --git a/_config.yml b/_config.yml index 79d451fe..79f153d5 100644 --- a/_config.yml +++ b/_config.yml @@ -49,11 +49,16 @@ google_site_verification: # fill in to your verification string # ↑ -------------------------- # The end of `jekyll-seo-tag` settings -google_analytics: - id: # fill in your Google Analytics ID - -goatcounter: - id: # fill in your Goatcounter ID +# Web Analytics Settings +analytics: + google: + id: # fill in your Google Analytics ID + goatcounter: + id: # fill in your GoatCounter ID + +# Pageviews settings +pageviews: + provider: # now only supports 'goatcounter' # Prefer color scheme setting. # diff --git a/_includes/analytics/goatcounter.html b/_includes/analytics/goatcounter.html new file mode 100644 index 00000000..78c90b72 --- /dev/null +++ b/_includes/analytics/goatcounter.html @@ -0,0 +1,6 @@ + + diff --git a/_includes/analytics/google.html b/_includes/analytics/google.html new file mode 100644 index 00000000..d0aac651 --- /dev/null +++ b/_includes/analytics/google.html @@ -0,0 +1,13 @@ + + + diff --git a/_includes/goatcounter.html b/_includes/goatcounter.html deleted file mode 100644 index 4d21d21e..00000000 --- a/_includes/goatcounter.html +++ /dev/null @@ -1,8 +0,0 @@ - - - - diff --git a/_includes/google-analytics.html b/_includes/google-analytics.html deleted file mode 100644 index e5e5119e..00000000 --- a/_includes/google-analytics.html +++ /dev/null @@ -1,14 +0,0 @@ - - - - diff --git a/_includes/head.html b/_includes/head.html index 9bad78a7..7c093597 100644 --- a/_includes/head.html +++ b/_includes/head.html @@ -72,7 +72,7 @@ {% endif %} - {% if jekyll.environment == 'production' and site.google_analytics.id != empty and site.google_analytics.id %} + {% if jekyll.environment == 'production' and site.analytics.google.id != empty and site.analytics.google.id %} diff --git a/_includes/js-selector.html b/_includes/js-selector.html index 1a1fa580..b37d7103 100644 --- a/_includes/js-selector.html +++ b/_includes/js-selector.html @@ -95,19 +95,32 @@ {% endif %} + +{% if page.layout == 'post' %} + {% assign provider = site.pageviews.provider %} + + {% if provider and provider != empty %} + {% case provider %} + {% when 'goatcounter' %} + {% if site.analytics[provider].id != empty and site.analytics[provider].id %} + {% include pageviews/{{ provider }}.html %} + {% endif %} + {% endcase %} + {% endif %} +{% endif %} + {% if jekyll.environment == 'production' %} {% if site.pwa.enabled %} {% endif %} - - {% if site.google_analytics.id != empty and site.google_analytics.id %} - {% include google-analytics.html %} - {% endif %} - - - {% if site.goatcounter.id != empty and site.goatcounter.id %} - {% include 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 00000000..af536dbd --- /dev/null +++ b/_includes/pageviews/goatcounter.html @@ -0,0 +1,18 @@ + + diff --git a/_layouts/post.html b/_layouts/post.html index f7818bf6..f666d716 100644 --- a/_layouts/post.html +++ b/_layouts/post.html @@ -74,12 +74,22 @@

{{ page.title }}

- - {% include read-time.html content=content prompt=true lang=lang %} +
+ + {% 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 %} +
- -
diff --git a/_sass/layout/post.scss b/_sass/layout/post.scss index efbde822..a6dc878c 100644 --- a/_sass/layout/post.scss +++ b/_sass/layout/post.scss @@ -15,7 +15,7 @@ } h1 + .post-meta { - > span + span::before { + span + span::before { @include dot; }