diff --git a/config.toml b/config.toml index 7dd3b9def..00572336b 100644 --- a/config.toml +++ b/config.toml @@ -585,6 +585,11 @@ # Cookie consent config # Cookie 许可配置 + # Ads config + [params.ads] + enable = false + [params.ads.google] + id = "" [params.cookieconsent] enable = false # text strings used for Cookie consent banner diff --git a/layouts/partials/assets.html b/layouts/partials/assets.html index 75b69c631..40fc851bf 100644 --- a/layouts/partials/assets.html +++ b/layouts/partials/assets.html @@ -206,3 +206,6 @@ {{- end -}} {{- partial "plugin/analytics.html" . -}} + +{{- partial "plugin/ads.html" . -}} + diff --git a/layouts/partials/init.html b/layouts/partials/init.html index f6794fb59..3b9e05c1f 100644 --- a/layouts/partials/init.html +++ b/layouts/partials/init.html @@ -15,6 +15,7 @@ {{- .Scratch.Set "cdn" $cdn -}} {{- .Scratch.Set "fingerprint" .Site.Params.fingerprint -}} {{- .Scratch.Set "analytics" .Site.Params.analytics -}} + {{- .Scratch.Set "ads" .Site.Params.ads -}} {{- .Scratch.Set "comment" $params.comment -}} {{- if eq .Params.comment true -}} {{- .Scratch.Set "comment" .Site.Params.comment -}} diff --git a/layouts/partials/plugin/ads.html b/layouts/partials/plugin/ads.html new file mode 100644 index 000000000..3e59b6cab --- /dev/null +++ b/layouts/partials/plugin/ads.html @@ -0,0 +1,8 @@ +{{- $ads := .Scratch.Get "ads" | default dict -}} +{{- if $ads.enable -}} + {{- with $ads.google.id -}} + + {{- end -}} + +{{- end -}}