From e1af133748dbd6bcce3bb9885f4e6cb45a9b8b3c Mon Sep 17 00:00:00 2001 From: Maxim Lebedev Date: Fri, 25 Dec 2020 20:02:58 +0500 Subject: [PATCH] :sparkles: Added Cloudflare WebAnalytics module --- cloudflare/README.md | 38 +++++++++++++++++++ cloudflare/config.yaml | 8 ++++ cloudflare/go.mod | 3 ++ .../layouts/partials/web-analytics.html | 5 +++ 4 files changed, 54 insertions(+) create mode 100644 cloudflare/README.md create mode 100644 cloudflare/config.yaml create mode 100644 cloudflare/go.mod create mode 100644 cloudflare/layouts/partials/web-analytics.html diff --git a/cloudflare/README.md b/cloudflare/README.md new file mode 100644 index 0000000..28ece47 --- /dev/null +++ b/cloudflare/README.md @@ -0,0 +1,38 @@ +# Cloudflare +[Cloudflare](https://cloudflare.com/) tools for compiled Hugo-website. + +## Install +### Config +[Import module](https://gohugo.io/hugo-modules/use-modules/#use-a-module-for-a-theme) in your site +configuration: + +```yaml +imports: +- path: gitlab.com/toby3d/hugo/cloudflare +``` + +Then, connect and configure the necessary/all modules. + +## Web Analytics +[See the official Cloudflare documentation](https://blog.cloudflare.com/privacy-first-web-analytics/) +about how it works and how to get the token. + +### Install +#### Config +```yaml +baseUrl: https://example.com/ +params: + cloudflare: + webAnalytics: 1d59a54b73a94728a4a9ed1b09767b1f +``` + +#### Template +Inject `cloudflare/web-analytics` partial in your `` (preferably as close as possible to the closing tag): + +```html +... + + ... + {{ partial "cloudflare/web-analytics" . }} + +``` diff --git a/cloudflare/config.yaml b/cloudflare/config.yaml new file mode 100644 index 0000000..3f9ec84 --- /dev/null +++ b/cloudflare/config.yaml @@ -0,0 +1,8 @@ +--- +module: + hugoVersion: + extended: false + min: "0.79.0" + mounts: + - source: layouts/partials + target: layouts/partials/cloudflare \ No newline at end of file diff --git a/cloudflare/go.mod b/cloudflare/go.mod new file mode 100644 index 0000000..7001014 --- /dev/null +++ b/cloudflare/go.mod @@ -0,0 +1,3 @@ +module gitlab.com/toby3d/hugo/cloudflare + +go 1.15 diff --git a/cloudflare/layouts/partials/web-analytics.html b/cloudflare/layouts/partials/web-analytics.html new file mode 100644 index 0000000..3c8025d --- /dev/null +++ b/cloudflare/layouts/partials/web-analytics.html @@ -0,0 +1,5 @@ +{{ with $.Site.Params.cloudflare.webAnalytics }} + + + +{{ end }} \ No newline at end of file