hugo-toha/layouts/partials/analytics.html
Aaron Qian 02db3d3044
Bundling JS with ESBuild (#702)
* add npm dependencies used in this theme

* implement helper to configure JS and ESBuild

* migrate jquery popper.js bootstrap fontawesome to js bundle

* refactor main.js into smaller pieces, and moved navbar.js to assets

* remove list.js. It adjusts post card height to be the same, but is actually not needed.

* refactored notes.js, search.js, single.js into application.js

* move ityped to js asset, implement experiences horizontal vertical line in css

* align recent post height via css

* migrated home.js and refactored into various sections

* migrated darkMode feature to js bundle

* moved mermaid feature to js bundle

* migrate syntax highlight to js bundle

* migrate katex ( js portion ) to js bundle

* migrate pdf-js to js bundle by delegating to cdn

* set explicit comparisions for feature envvars so js can properly optimize

* removed goat-counter

* more fixes for broken achievements and small bugs

* more bug fixes

* allow configuration of hightlight.js, fix video-player shortcode

* remove jquery all together

* add null handling and fix merge conflicts

Co-authored-by: Aaron Qian <aaron@yeet.io>
2023-01-06 00:42:54 +06:00

53 lines
2 KiB
HTML

<!-- Add Analytics if enabled in configuration -->
{{ with site.Params.features.analytics }}
{{ if .enabled }}
{{ with .services }}
<!-- Google Analytics -->
{{ with .google }}
{{ $privacyConfig:= dict (slice "Site" "Config" "Privacy" "GoogleAnalytics") $.Site.Config.Privacy.GoogleAnalytics }}
{{ $analyticsConfig := dict (slice "Site" "GoogleAnalytics") .id }}
{{ template "_internal/google_analytics.html" (merge $privacyConfig $analyticsConfig) }}
{{ end }}
<!-- Counter.dev -->
{{ with .counterDev }}
<script src="https://cdn.counter.dev/script.js"
data-id="{{ .id }}"
data-utcoffset="1"
></script>
{{ end }}
<!-- GoatCounter -->
{{ with .goatCounter }}
<script
data-goatcounter="https://{{ .code }}.goatcounter.com/count"
async
src="//gc.zgo.at/count.js"
></script>
{{ end }}
<!-- Piwik/Matomo -->
{{ with .matomo }}
<!-- Matomo -->
<script>
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//{{ .instance }}/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '{{ .siteId }}']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();
</script>
{{ end }}
{{ end }}
{{ end }}
{{ end }}
<!-- Keep backwards compatibility and consistency with HUGO defaults -->
{{ if site.GoogleAnalytics }}
{{ template "_internal/google_analytics.html" . }}
{{ end }}