diff options
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | exampleSite/config.toml | 6 | ||||
-rw-r--r-- | layouts/partials/fathom.html | 19 | ||||
-rw-r--r-- | layouts/partials/footer.html | 4 | ||||
-rw-r--r-- | package.json | 2 | ||||
-rw-r--r-- | yarn.lock | 8 |
6 files changed, 35 insertions, 6 deletions
@@ -12,7 +12,7 @@ A minimalist theme for Hugo, built with Tailwind CSS. - Responsive - Super-fast - [100% in Lighthouse tests](https://lighthouse-dot-webdotdevsite.appspot.com//lh/html?url=https%3A%2F%2Fbento-hugo-theme.netlify.app%2F) - Tailwind CSS with PostCSS: super tiny CSS file -- Google Analytics and Disqus integration +- Google Analytics, Fathom Analytics and Disqus integration - Syntax Highlighting with GitHub theme - Full content RSS - Turbolinks: no page refresh diff --git a/exampleSite/config.toml b/exampleSite/config.toml index 5e321f9..790e269 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -51,6 +51,12 @@ disqusShortname = "bento-hugo-theme" # Bio is shown in the end of posts authorBio = "Bento is a doggo who likes to code. Follow him on <a href='#'>Twitter</a>" +# If you want to use fathom(https://usefathom.com) for analytics, add this section +[params.fathomAnalytics] + siteID = "XXXXX" + # Default value is cdn.usefathom.com, overwrite this if you are self-hosting + serverURL = "analytics.example.com" + # Items in the top menu [menu] [[menu.main]] diff --git a/layouts/partials/fathom.html b/layouts/partials/fathom.html new file mode 100644 index 0000000..4536a34 --- /dev/null +++ b/layouts/partials/fathom.html @@ -0,0 +1,19 @@ +<script> + (function(f, a, t, h, o, m){ + a[h]=a[h]||function(){ + (a[h].q=a[h].q||[]).push(arguments) + }; + o=f.createElement('script'), + m=f.getElementsByTagName('script')[0]; + o.async=1; o.src=t; o.id='fathom-script'; + m.parentNode.insertBefore(o,m) + })(document, window, '//{{ .Site.Params.fathomAnalytics.serverURL | default "cdn.usefathom.com" }}/tracker.js', 'fathom'); + fathom('set', 'siteId', '{{ .Site.Params.fathomAnalytics.siteID }}'); + fathom('trackPageview'); + + document.addEventListener('turbolinks:load', (e) => { + if (typeof window.fathom === 'function') { + window.fathom('trackPageview'); + } + }); +</script> diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index 0a3417b..54d6c8f 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -72,3 +72,7 @@ </script> {{end}} {{ template "_internal/google_analytics.html" . }} + +{{ if and .Site.Params.fathomAnalytics .Site.Params.fathomAnalytics.siteID }} + {{- partial "fathom" . -}} +{{ end }}
\ No newline at end of file diff --git a/package.json b/package.json index 9b4a8a0..e6e2608 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "postcss": "^7.0.32", "postcss-cli": "^7.1.1", "postcss-import": "^12.0.1", - "tailwindcss": "^1.5.1" + "tailwindcss": "^1.6.1" }, "browserslist": [ "last 1 version", @@ -1075,10 +1075,10 @@ supports-color@^7.1.0: dependencies: has-flag "^4.0.0" -tailwindcss@^1.5.1: - version "1.5.1" - resolved "https://registry.yarnpkg.com/tailwindcss/-/tailwindcss-1.5.1.tgz#a3eb10024f8e10786b8b6badcf9665b013bd03ee" - integrity sha512-mBOxIk+U+9xECC6wllWiupPVfLuwTDvHb4d+8XTdZ8oYrZEH+NpFSlbATF5xWuCJQxDOZ1Dz7C0KN5tylcFhFg== +tailwindcss@^1.6.1: + version "1.6.1" + resolved "https://registry.yarnpkg.com/tailwindcss/-/tailwindcss-1.6.1.tgz#0fbd031848066665fe82dc89eeb30c3d9c4f83ba" + integrity sha512-hg20uPJTi3q4Ib6YSMb5p9ZEpp73O/5p3SxWFud45ePXAVl3/DyGMHhjTFDMVX5YqmLrPcEggxBw3Vx9TLuxyA== dependencies: "@fullhuman/postcss-purgecss" "^2.1.2" autoprefixer "^9.4.5" |