Skip to content

Commit

Permalink
feat: add support for Plausible Analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
razonyang committed Sep 13, 2022
1 parent 2d3570c commit 9340210
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions exampleSite/config/_default/params.toml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ viewer = true # Image Viewer

[analytics]
# baidu = "" # Baidu Analytics
# plausible = "razonyang.com,hbs.razonyang.com" # Multiple domains separate by comma.
# plausibleScript = "" # Specify the self-hosted script or extended script. Default to https://plausible.io/js/script.js.

# Site verification
[siteVerification]
Expand Down
2 changes: 2 additions & 0 deletions exampleSite/content/docs/configuration/site-params/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ The site parameters are located in `config/_default/params.toml` by default.
| **Analytics**
| `analytics` | Object | - | Analytics configuration.
| `analytics.baidu` | String | - | Baidu Analytics.
| `analytics.plausible` | String | - | Plausible Analytics Domains. Multiple domains separate by comma.
| `analytics.plausibleScript` | String | `https://plausible.io/js/script.js` | Specify the self-hosted Plausible Analytics script or [extended script](https://plausible.io/docs/script-extensions).
| `googleAdsense` | String | - | Google Adsense.
| `customCSS` | Array | - | See also [custom assets]({{< ref "/docs/advanced/custom-assets#external-assets" >}}).
| `customJS` | Array | - | See also [custom assets]({{< ref "/docs/advanced/custom-assets#external-assets" >}}).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ authors = ["RazonYang"]
| **Analytics**
| `analytics` | Object | - | Analytics.
| `analytics.baidu` | String | - | 百度统计
| `analytics.plausible` | String | - | Plausible Analytics Domains. Multiple domains separate by comma.
| `analytics.plausibleScript` | String | `https://plausible.io/js/script.js` | Specify the self-hosted Plausible Analytics script or [extended script](https://plausible.io/docs/script-extensions).
| **Others**
| `googleAdsense` | String | - | Google Adsense。
| `customCSS` | Array | - | 自定义 CSS, 主要用于导入外部。 请查阅[自定义资源](#自定义资源)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ authors = ["RazonYang"]
| **Analytics**
| `analytics` | Object | - | Analytics.
| `analytics.baidu` | String | - | 百度統計
| `analytics.plausible` | String | - | Plausible Analytics Domains. Multiple domains separate by comma.
| `analytics.plausibleScript` | String | `https://plausible.io/js/script.js` | Specify the self-hosted Plausible Analytics script or [extended script](https://plausible.io/docs/script-extensions).
| **Others**
| `googleAdsense` | String | - | Google Adsense。
| `customCSS` | Array | - | 自定義 CSS, 主要用於導入外部。 請查閱[自定義資源](#自定義資源)
Expand Down
4 changes: 4 additions & 0 deletions layouts/partials/assets/plausible-analytics/js.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{{- with .Site.Params.analytics.plausible }}
{{- $script := default "https://plausible.io/js/script.js" $.Site.Params.analytics.plausibleScript }}
<script defer data-domain="{{ . }}" src="{{ $script }}"></script>
{{- end }}
1 change: 1 addition & 0 deletions layouts/partials/head/assets.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
{{- partial "assets/math/css" . }}
{{- partial "assets/viewer/css" . }}
{{- partial "assets/docsearch/css" . -}}
{{- partial "assets/plausible-analytics/js" . -}}

0 comments on commit 9340210

Please sign in to comment.