diff --git a/_config.yml b/_config.yml index 79d451f..79f153d 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 +# Web Analytics Settings +analytics: + google: + id: # fill in your Google Analytics ID + goatcounter: + id: # fill in your GoatCounter 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 0000000..78c90b7 --- /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 0000000..d0aac65 --- /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 4d21d21..0000000 --- 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 e5e5119..0000000 --- a/_includes/google-analytics.html +++ /dev/null @@ -1,14 +0,0 @@ - - - - diff --git a/_includes/head.html b/_includes/head.html index 9bad78a..7c09359 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 1a1fa58..b37d710 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 0000000..af536db --- /dev/null +++ b/_includes/pageviews/goatcounter.html @@ -0,0 +1,18 @@ + + diff --git a/_layouts/post.html b/_layouts/post.html index f7818bf..f666d71 100644 --- a/_layouts/post.html +++ b/_layouts/post.html @@ -74,12 +74,22 @@ tail_includes: - - {% 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 efbde82..a6dc878 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; }