diff --git a/config/privacy/privacyConfig.go b/config/privacy/privacyConfig.go index 0241b5704..64bbe71bb 100644 --- a/config/privacy/privacyConfig.go +++ b/config/privacy/privacyConfig.go @@ -72,8 +72,12 @@ type Vimeo struct { // YouTube holds the privacy configuration settingsrelated to the YouTube shortcode. type YouTube struct { - Service `mapstructure:",squash"` - NoCookie bool + Service `mapstructure:",squash"` + + // When you turn on privacy-enhanced mode, + // YouTube won’t store information about visitors on your website + // unless they play the video. + PrivacyEnhanced bool } func DecodeConfig(cfg config.Provider) (pc Config, err error) { diff --git a/config/privacy/privacyConfig_test.go b/config/privacy/privacyConfig_test.go index f8e2ebbd1..bca53f167 100644 --- a/config/privacy/privacyConfig_test.go +++ b/config/privacy/privacyConfig_test.go @@ -44,7 +44,7 @@ disable = true disable = true [privacy.youtube] disable = true -noCookie = true +privacyEnhanced = true ` cfg, err := config.FromConfigString(tomlConfig, "toml") assert.NoError(err) @@ -61,7 +61,7 @@ noCookie = true assert.True(pc.Tweet.Disable) assert.True(pc.Vimeo.Disable) - assert.True(pc.YouTube.NoCookie) + assert.True(pc.YouTube.PrivacyEnhanced) assert.True(pc.YouTube.Disable) } @@ -74,7 +74,7 @@ someOtherValue = "foo" [Privacy] [Privacy.YouTube] -NoCOOKIE = true +PrivacyENhanced = true ` cfg, err := config.FromConfigString(tomlConfig, "toml") assert.NoError(err) @@ -82,7 +82,7 @@ NoCOOKIE = true pc, err := DecodeConfig(cfg) assert.NoError(err) assert.NotNil(pc) - assert.True(pc.YouTube.NoCookie) + assert.True(pc.YouTube.PrivacyEnhanced) } func TestDecodeConfigDefault(t *testing.T) { @@ -91,5 +91,5 @@ func TestDecodeConfigDefault(t *testing.T) { pc, err := DecodeConfig(viper.New()) assert.NoError(err) assert.NotNil(pc) - assert.False(pc.YouTube.NoCookie) + assert.False(pc.YouTube.PrivacyEnhanced) } diff --git a/hugolib/config_test.go b/hugolib/config_test.go index 8bf7ea8b3..f6306dec1 100644 --- a/hugolib/config_test.go +++ b/hugolib/config_test.go @@ -377,13 +377,13 @@ someOtherValue = "foo" [privacy] [privacy.youtube] -noCookie = true +privacyEnhanced = true ` b := newTestSitesBuilder(t) b.WithConfigFile("toml", tomlConfig) b.Build(BuildCfg{SkipRender: true}) - assert.True(b.H.Sites[0].Info.PrivacyConfig.YouTube.NoCookie) + assert.True(b.H.Sites[0].Info.PrivacyConfig.YouTube.PrivacyEnhanced) } diff --git a/tpl/tplimpl/embedded/templates.autogen.go b/tpl/tplimpl/embedded/templates.autogen.go index 71a1fd14f..7ba6a3043 100644 --- a/tpl/tplimpl/embedded/templates.autogen.go +++ b/tpl/tplimpl/embedded/templates.autogen.go @@ -287,13 +287,14 @@ if (!doNotTrack) { {{- end -}}`}, {`shortcodes/youtube.html`, `{{- $pc := .Page.Site.PrivacyConfig.YouTube -}} {{- if not $pc.Disable -}} +{{ $ytHost := cond $pc.PrivacyEnhanced "www.youtube-nocookie.com" "www.youtube.com" }} {{ if .IsNamedParams }}
-
{{ else }}
- +
{{ end }} {{- end -}}`}, diff --git a/tpl/tplimpl/embedded/templates/shortcodes/youtube.html b/tpl/tplimpl/embedded/templates/shortcodes/youtube.html index 2bdcb7441..3a3ff4241 100755 --- a/tpl/tplimpl/embedded/templates/shortcodes/youtube.html +++ b/tpl/tplimpl/embedded/templates/shortcodes/youtube.html @@ -1,12 +1,13 @@ {{- $pc := .Page.Site.PrivacyConfig.YouTube -}} {{- if not $pc.Disable -}} +{{ $ytHost := cond $pc.PrivacyEnhanced "www.youtube-nocookie.com" "www.youtube.com" }} {{ if .IsNamedParams }}
-
{{ else }}
- +
{{ end }} {{- end -}} \ No newline at end of file