Skip to content

Commit d4d49e0

Browse files
jmooringbep
authored andcommitted
hugolib: Deprecate site methods Author, Authors, and Social
Closes gohugoio#12228
1 parent 78178d0 commit d4d49e0

File tree

10 files changed

+42
-36
lines changed

10 files changed

+42
-36
lines changed

config/allconfig/allconfig.go

+2
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,11 @@ type Config struct {
103103
RootConfig
104104

105105
// Author information.
106+
// Deprecated: Use taxonomies instead.
106107
Author map[string]any
107108

108109
// Social links.
110+
// Deprecated: Use .Site.Params instead.
109111
Social map[string]string
110112

111113
// The build configuration section contains build-related configuration options.

hugolib/page__meta.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ func (p *pageMeta) Aliases() []string {
106106
return p.pageConfig.Aliases
107107
}
108108

109-
// Deprecated: use taxonomies.
109+
// Deprecated: Use taxonomies instead.
110110
func (p *pageMeta) Author() page.Author {
111-
hugo.Deprecate(".Author", "Use taxonomies.", "v0.98.0")
111+
hugo.Deprecate(".Page.Author", "Use taxonomies instead.", "v0.98.0")
112112
authors := p.Authors()
113113

114114
for _, author := range authors {
@@ -117,9 +117,9 @@ func (p *pageMeta) Author() page.Author {
117117
return page.Author{}
118118
}
119119

120-
// Deprecated: use taxonomies.
120+
// Deprecated: Use taxonomies instead.
121121
func (p *pageMeta) Authors() page.AuthorList {
122-
hugo.Deprecate(".Author", "Use taxonomies.", "v0.112.0")
122+
hugo.Deprecate(".Page.Authors", "Use taxonomies instead.", "v0.112.0")
123123
return nil
124124
}
125125

hugolib/site_new.go

+6
Original file line numberDiff line numberDiff line change
@@ -447,15 +447,21 @@ func (s *Site) Params() maps.Params {
447447
return s.conf.Params
448448
}
449449

450+
// Deprecated: Use taxonomies instead.
450451
func (s *Site) Author() map[string]any {
452+
hugo.Deprecate(".Site.Author", "Use taxonomies instead.", "v0.124.0")
451453
return s.conf.Author
452454
}
453455

456+
// Deprecated: Use taxonomies instead.
454457
func (s *Site) Authors() page.AuthorList {
458+
hugo.Deprecate(".Site.Authors", "Use taxonomies instead.", "v0.124.0")
455459
return page.AuthorList{}
456460
}
457461

462+
// Deprecated: Use .Site.Params instead.
458463
func (s *Site) Social() map[string]string {
464+
hugo.Deprecate(".Site.Social", "Use .Site.Params instead.", "v0.124.0")
459465
return s.conf.Social
460466
}
461467

resources/page/page.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ type AlternativeOutputFormatsProvider interface {
5252

5353
// AuthorProvider provides author information.
5454
type AuthorProvider interface {
55-
// Deprecated.
55+
// Deprecated: Use taxonomies instead.
5656
Author() Author
57-
// Deprecated.
57+
// Deprecated: Use taxonomies instead.
5858
Authors() AuthorList
5959
}
6060

resources/page/page_author.go

+3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414
package page
1515

1616
// AuthorList is a list of all authors and their metadata.
17+
// Deprecated: Use taxonomies instead.
1718
type AuthorList map[string]Author
1819

1920
// Author contains details about the author of a page.
21+
// Deprecated: Use taxonomies instead.
2022
type Author struct {
2123
GivenName string
2224
FamilyName string
@@ -41,4 +43,5 @@ type Author struct {
4143
// - youtube
4244
// - linkedin
4345
// - skype
46+
// Deprecated: Use taxonomies instead.
4447
type AuthorSocial map[string]string

resources/page/page_nop.go

+2
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,12 @@ func (p *nopPage) RSSLink() template.URL {
7979
return ""
8080
}
8181

82+
// Deprecated: Use taxonomies instead.
8283
func (p *nopPage) Author() Author {
8384
return Author{}
8485
}
8586

87+
// Deprecated: Use taxonomies instead.
8688
func (p *nopPage) Authors() AuthorList {
8789
return nil
8890
}

resources/page/site.go

+10-4
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,13 @@ type Site interface {
108108
// Returns the site config.
109109
Config() SiteConfig
110110

111-
// Author is deprecated and will be removed in a future release.
111+
// Deprecated: Use taxonomies instead.
112112
Author() map[string]interface{}
113113

114-
// Authors is deprecated and will be removed in a future release.
114+
// Deprecated: Use taxonomies instead.
115115
Authors() AuthorList
116116

117-
// Returns the social links for this site.
117+
// Deprecated: Use .Site.Params instead.
118118
Social() map[string]string
119119

120120
// Deprecated: Use Config().Services.GoogleAnalytics instead.
@@ -165,16 +165,19 @@ func (s *siteWrapper) Key() string {
165165
return s.s.Language().Lang
166166
}
167167

168+
// // Deprecated: Use .Site.Params instead.
168169
func (s *siteWrapper) Social() map[string]string {
169170
return s.s.Social()
170171
}
171172

173+
// Deprecated: Use taxonomies instead.
172174
func (s *siteWrapper) Author() map[string]interface{} {
173175
return s.s.Author()
174176
}
175177

178+
// Deprecated: Use taxonomies instead.
176179
func (s *siteWrapper) Authors() AuthorList {
177-
return AuthorList{}
180+
return s.s.Authors()
178181
}
179182

180183
// Deprecated: Use .Site.Config.Services.GoogleAnalytics.ID instead.
@@ -321,14 +324,17 @@ type testSite struct {
321324
l *langs.Language
322325
}
323326

327+
// Deprecated: Use taxonomies instead.
324328
func (s testSite) Author() map[string]interface{} {
325329
return nil
326330
}
327331

332+
// Deprecated: Use taxonomies instead.
328333
func (s testSite) Authors() AuthorList {
329334
return AuthorList{}
330335
}
331336

337+
// Deprecated: Use .Site.Params instead.
332338
func (s testSite) Social() map[string]string {
333339
return make(map[string]string)
334340
}

resources/page/testhelpers_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,12 @@ func (p *testPage) AlternativeOutputFormats() OutputFormats {
127127
panic("testpage: not implemented")
128128
}
129129

130+
// Deprecated: Use taxonomies instead.
130131
func (p *testPage) Author() Author {
131132
return Author{}
132133
}
133134

135+
// Deprecated: Use taxonomies instead.
134136
func (p *testPage) Authors() AuthorList {
135137
return nil
136138
}

tpl/tplimpl/embedded/templates/opengraph.html

+4-11
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,11 @@
3434
{{ end }}{{ end }}
3535
{{- end }}
3636

37-
{{- /* Deprecate site.Social.facebook_admin in favor of site.Params.social.facebook_admin */}}
38-
{{- $facebookAdmin := "" }}
37+
{{- /* Facebook Page Admin ID for Domain Insights */}}
3938
{{- with site.Params.social }}
4039
{{- if reflect.IsMap . }}
41-
{{- $facebookAdmin = .facebook_admin }}
42-
{{- end }}
43-
{{- else }}
44-
{{- with site.Social.facebook_admin }}
45-
{{- $facebookAdmin = . }}
46-
{{- warnf "The social key in site configuration is deprecated. Use params.social.facebook_admin instead." }}
40+
{{- with .facebook_admin }}
41+
<meta property="fb:admins" content="{{ . }}" />
42+
{{- end }}
4743
{{- end }}
4844
{{- end }}
49-
50-
{{- /* Facebook Page Admin ID for Domain Insights */}}
51-
{{ with $facebookAdmin }}<meta property="fb:admins" content="{{ . }}" />{{ end }}

tpl/tplimpl/embedded/templates/twitter_cards.html

+7-15
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,15 @@
88
<meta name="twitter:title" content="{{ .Title }}"/>
99
<meta name="twitter:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end -}}"/>
1010

11-
{{- /* Deprecate site.Social.twitter in favor of site.Params.social.twitter */}}
1211
{{- $twitterSite := "" }}
1312
{{- with site.Params.social }}
1413
{{- if reflect.IsMap . }}
15-
{{- $twitterSite = .twitter }}
14+
{{- with .twitter }}
15+
{{- $content := . }}
16+
{{- if not (strings.HasPrefix . "@") }}
17+
{{- $content = printf "@%v" . }}
18+
{{- end }}
19+
<meta name="twitter:site" content="{{ $content }}"/>
20+
{{- end }}
1621
{{- end }}
17-
{{- else }}
18-
{{- with site.Social.twitter }}
19-
{{- $twitterSite = . }}
20-
{{- warnf "The social key in site configuration is deprecated. Use params.social.twitter instead." }}
21-
{{- end }}
22-
{{- end }}
23-
24-
{{- with $twitterSite }}
25-
{{- $content := . }}
26-
{{- if not (strings.HasPrefix . "@") }}
27-
{{- $content = printf "@%v" $twitterSite }}
28-
{{- end }}
29-
<meta name="twitter:site" content="{{ $content }}"/>
3022
{{- end }}

0 commit comments

Comments
 (0)