summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe Mooring <joe.mooring@veriphor.com>2024-03-12 11:16:05 -0700
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2024-03-15 17:26:45 +0100
commitd4d49e0f0ec53ef7e105c51b5c6fd198c86acb7e (patch)
tree886d5118def4fe3fe5bb5c293740d898be39b638
parent78178d0c2a10e7793a41f8f66b3a4a6e4f70ef7e (diff)
hugolib: Deprecate site methods Author, Authors, and Social
Closes #12228
-rw-r--r--config/allconfig/allconfig.go2
-rw-r--r--hugolib/page__meta.go8
-rw-r--r--hugolib/site_new.go6
-rw-r--r--resources/page/page.go4
-rw-r--r--resources/page/page_author.go3
-rw-r--r--resources/page/page_nop.go2
-rw-r--r--resources/page/site.go14
-rw-r--r--resources/page/testhelpers_test.go2
-rw-r--r--tpl/tplimpl/embedded/templates/opengraph.html15
-rw-r--r--tpl/tplimpl/embedded/templates/twitter_cards.html22
10 files changed, 42 insertions, 36 deletions
diff --git a/config/allconfig/allconfig.go b/config/allconfig/allconfig.go
index 590f2ba60..3a7908d55 100644
--- a/config/allconfig/allconfig.go
+++ b/config/allconfig/allconfig.go
@@ -103,9 +103,11 @@ type Config struct {
RootConfig
// Author information.
+ // Deprecated: Use taxonomies instead.
Author map[string]any
// Social links.
+ // Deprecated: Use .Site.Params instead.
Social map[string]string
// The build configuration section contains build-related configuration options.
diff --git a/hugolib/page__meta.go b/hugolib/page__meta.go
index 8c148923d..7ab904357 100644
--- a/hugolib/page__meta.go
+++ b/hugolib/page__meta.go
@@ -106,9 +106,9 @@ func (p *pageMeta) Aliases() []string {
return p.pageConfig.Aliases
}
-// Deprecated: use taxonomies.
+// Deprecated: Use taxonomies instead.
func (p *pageMeta) Author() page.Author {
- hugo.Deprecate(".Author", "Use taxonomies.", "v0.98.0")
+ hugo.Deprecate(".Page.Author", "Use taxonomies instead.", "v0.98.0")
authors := p.Authors()
for _, author := range authors {
@@ -117,9 +117,9 @@ func (p *pageMeta) Author() page.Author {
return page.Author{}
}
-// Deprecated: use taxonomies.
+// Deprecated: Use taxonomies instead.
func (p *pageMeta) Authors() page.AuthorList {
- hugo.Deprecate(".Author", "Use taxonomies.", "v0.112.0")
+ hugo.Deprecate(".Page.Authors", "Use taxonomies instead.", "v0.112.0")
return nil
}
diff --git a/hugolib/site_new.go b/hugolib/site_new.go
index 21d5ace96..97b46e358 100644
--- a/hugolib/site_new.go
+++ b/hugolib/site_new.go
@@ -447,15 +447,21 @@ func (s *Site) Params() maps.Params {
return s.conf.Params
}
+// Deprecated: Use taxonomies instead.
func (s *Site) Author() map[string]any {
+ hugo.Deprecate(".Site.Author", "Use taxonomies instead.", "v0.124.0")
return s.conf.Author
}
+// Deprecated: Use taxonomies instead.
func (s *Site) Authors() page.AuthorList {
+ hugo.Deprecate(".Site.Authors", "Use taxonomies instead.", "v0.124.0")
return page.AuthorList{}
}
+// Deprecated: Use .Site.Params instead.
func (s *Site) Social() map[string]string {
+ hugo.Deprecate(".Site.Social", "Use .Site.Params instead.", "v0.124.0")
return s.conf.Social
}
diff --git a/resources/page/page.go b/resources/page/page.go
index 56ba04d74..f995ee641 100644
--- a/resources/page/page.go
+++ b/resources/page/page.go
@@ -52,9 +52,9 @@ type AlternativeOutputFormatsProvider interface {
// AuthorProvider provides author information.
type AuthorProvider interface {
- // Deprecated.
+ // Deprecated: Use taxonomies instead.
Author() Author
- // Deprecated.
+ // Deprecated: Use taxonomies instead.
Authors() AuthorList
}
diff --git a/resources/page/page_author.go b/resources/page/page_author.go
index 58be20426..2b3282b1e 100644
--- a/resources/page/page_author.go
+++ b/resources/page/page_author.go
@@ -14,9 +14,11 @@
package page
// AuthorList is a list of all authors and their metadata.
+// Deprecated: Use taxonomies instead.
type AuthorList map[string]Author
// Author contains details about the author of a page.
+// Deprecated: Use taxonomies instead.
type Author struct {
GivenName string
FamilyName string
@@ -41,4 +43,5 @@ type Author struct {
// - youtube
// - linkedin
// - skype
+// Deprecated: Use taxonomies instead.
type AuthorSocial map[string]string
diff --git a/resources/page/page_nop.go b/resources/page/page_nop.go
index a8f42e4d3..d3813337d 100644
--- a/resources/page/page_nop.go
+++ b/resources/page/page_nop.go
@@ -79,10 +79,12 @@ func (p *nopPage) RSSLink() template.URL {
return ""
}
+// Deprecated: Use taxonomies instead.
func (p *nopPage) Author() Author {
return Author{}
}
+// Deprecated: Use taxonomies instead.
func (p *nopPage) Authors() AuthorList {
return nil
}
diff --git a/resources/page/site.go b/resources/page/site.go
index 8f268091f..df33485eb 100644
--- a/resources/page/site.go
+++ b/resources/page/site.go
@@ -108,13 +108,13 @@ type Site interface {
// Returns the site config.
Config() SiteConfig
- // Author is deprecated and will be removed in a future release.
+ // Deprecated: Use taxonomies instead.
Author() map[string]interface{}
- // Authors is deprecated and will be removed in a future release.
+ // Deprecated: Use taxonomies instead.
Authors() AuthorList
- // Returns the social links for this site.
+ // Deprecated: Use .Site.Params instead.
Social() map[string]string
// Deprecated: Use Config().Services.GoogleAnalytics instead.
@@ -165,16 +165,19 @@ func (s *siteWrapper) Key() string {
return s.s.Language().Lang
}
+// // Deprecated: Use .Site.Params instead.
func (s *siteWrapper) Social() map[string]string {
return s.s.Social()
}
+// Deprecated: Use taxonomies instead.
func (s *siteWrapper) Author() map[string]interface{} {
return s.s.Author()
}
+// Deprecated: Use taxonomies instead.
func (s *siteWrapper) Authors() AuthorList {
- return AuthorList{}
+ return s.s.Authors()
}
// Deprecated: Use .Site.Config.Services.GoogleAnalytics.ID instead.
@@ -321,14 +324,17 @@ type testSite struct {
l *langs.Language
}
+// Deprecated: Use taxonomies instead.
func (s testSite) Author() map[string]interface{} {
return nil
}
+// Deprecated: Use taxonomies instead.
func (s testSite) Authors() AuthorList {
return AuthorList{}
}
+// Deprecated: Use .Site.Params instead.
func (s testSite) Social() map[string]string {
return make(map[string]string)
}
diff --git a/resources/page/testhelpers_test.go b/resources/page/testhelpers_test.go
index e80ed422d..cedbc74e9 100644
--- a/resources/page/testhelpers_test.go
+++ b/resources/page/testhelpers_test.go
@@ -127,10 +127,12 @@ func (p *testPage) AlternativeOutputFormats() OutputFormats {
panic("testpage: not implemented")
}
+// Deprecated: Use taxonomies instead.
func (p *testPage) Author() Author {
return Author{}
}
+// Deprecated: Use taxonomies instead.
func (p *testPage) Authors() AuthorList {
return nil
}
diff --git a/tpl/tplimpl/embedded/templates/opengraph.html b/tpl/tplimpl/embedded/templates/opengraph.html
index f3f41121c..bbe4e5dd0 100644
--- a/tpl/tplimpl/embedded/templates/opengraph.html
+++ b/tpl/tplimpl/embedded/templates/opengraph.html
@@ -34,18 +34,11 @@
{{ end }}{{ end }}
{{- end }}
-{{- /* Deprecate site.Social.facebook_admin in favor of site.Params.social.facebook_admin */}}
-{{- $facebookAdmin := "" }}
+{{- /* Facebook Page Admin ID for Domain Insights */}}
{{- with site.Params.social }}
{{- if reflect.IsMap . }}
- {{- $facebookAdmin = .facebook_admin }}
- {{- end }}
-{{- else }}
- {{- with site.Social.facebook_admin }}
- {{- $facebookAdmin = . }}
- {{- warnf "The social key in site configuration is deprecated. Use params.social.facebook_admin instead." }}
+ {{- with .facebook_admin }}
+ <meta property="fb:admins" content="{{ . }}" />
+ {{- end }}
{{- end }}
{{- end }}
-
-{{- /* Facebook Page Admin ID for Domain Insights */}}
-{{ with $facebookAdmin }}<meta property="fb:admins" content="{{ . }}" />{{ end }}
diff --git a/tpl/tplimpl/embedded/templates/twitter_cards.html b/tpl/tplimpl/embedded/templates/twitter_cards.html
index e66a5029a..c445efdfc 100644
--- a/tpl/tplimpl/embedded/templates/twitter_cards.html
+++ b/tpl/tplimpl/embedded/templates/twitter_cards.html
@@ -8,23 +8,15 @@
<meta name="twitter:title" content="{{ .Title }}"/>
<meta name="twitter:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end -}}"/>
-{{- /* Deprecate site.Social.twitter in favor of site.Params.social.twitter */}}
{{- $twitterSite := "" }}
{{- with site.Params.social }}
{{- if reflect.IsMap . }}
- {{- $twitterSite = .twitter }}
+ {{- with .twitter }}
+ {{- $content := . }}
+ {{- if not (strings.HasPrefix . "@") }}
+ {{- $content = printf "@%v" . }}
+ {{- end }}
+ <meta name="twitter:site" content="{{ $content }}"/>
+ {{- end }}
{{- end }}
-{{- else }}
- {{- with site.Social.twitter }}
- {{- $twitterSite = . }}
- {{- warnf "The social key in site configuration is deprecated. Use params.social.twitter instead." }}
- {{- end }}
-{{- end }}
-
-{{- with $twitterSite }}
- {{- $content := . }}
- {{- if not (strings.HasPrefix . "@") }}
- {{- $content = printf "@%v" $twitterSite }}
- {{- end }}
-<meta name="twitter:site" content="{{ $content }}"/>
{{- end }}