mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
hugolib: Deprecate site methods Author, Authors, and Social
Closes #12228
This commit is contained in:
parent
78178d0c2a
commit
d4d49e0f0e
10 changed files with 42 additions and 36 deletions
|
@ -103,9 +103,11 @@ type Config struct {
|
||||||
RootConfig
|
RootConfig
|
||||||
|
|
||||||
// Author information.
|
// Author information.
|
||||||
|
// Deprecated: Use taxonomies instead.
|
||||||
Author map[string]any
|
Author map[string]any
|
||||||
|
|
||||||
// Social links.
|
// Social links.
|
||||||
|
// Deprecated: Use .Site.Params instead.
|
||||||
Social map[string]string
|
Social map[string]string
|
||||||
|
|
||||||
// The build configuration section contains build-related configuration options.
|
// The build configuration section contains build-related configuration options.
|
||||||
|
|
|
@ -106,9 +106,9 @@ func (p *pageMeta) Aliases() []string {
|
||||||
return p.pageConfig.Aliases
|
return p.pageConfig.Aliases
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated: use taxonomies.
|
// Deprecated: Use taxonomies instead.
|
||||||
func (p *pageMeta) Author() page.Author {
|
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()
|
authors := p.Authors()
|
||||||
|
|
||||||
for _, author := range authors {
|
for _, author := range authors {
|
||||||
|
@ -117,9 +117,9 @@ func (p *pageMeta) Author() page.Author {
|
||||||
return page.Author{}
|
return page.Author{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated: use taxonomies.
|
// Deprecated: Use taxonomies instead.
|
||||||
func (p *pageMeta) Authors() page.AuthorList {
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -447,15 +447,21 @@ func (s *Site) Params() maps.Params {
|
||||||
return s.conf.Params
|
return s.conf.Params
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use taxonomies instead.
|
||||||
func (s *Site) Author() map[string]any {
|
func (s *Site) Author() map[string]any {
|
||||||
|
hugo.Deprecate(".Site.Author", "Use taxonomies instead.", "v0.124.0")
|
||||||
return s.conf.Author
|
return s.conf.Author
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use taxonomies instead.
|
||||||
func (s *Site) Authors() page.AuthorList {
|
func (s *Site) Authors() page.AuthorList {
|
||||||
|
hugo.Deprecate(".Site.Authors", "Use taxonomies instead.", "v0.124.0")
|
||||||
return page.AuthorList{}
|
return page.AuthorList{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use .Site.Params instead.
|
||||||
func (s *Site) Social() map[string]string {
|
func (s *Site) Social() map[string]string {
|
||||||
|
hugo.Deprecate(".Site.Social", "Use .Site.Params instead.", "v0.124.0")
|
||||||
return s.conf.Social
|
return s.conf.Social
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,9 +52,9 @@ type AlternativeOutputFormatsProvider interface {
|
||||||
|
|
||||||
// AuthorProvider provides author information.
|
// AuthorProvider provides author information.
|
||||||
type AuthorProvider interface {
|
type AuthorProvider interface {
|
||||||
// Deprecated.
|
// Deprecated: Use taxonomies instead.
|
||||||
Author() Author
|
Author() Author
|
||||||
// Deprecated.
|
// Deprecated: Use taxonomies instead.
|
||||||
Authors() AuthorList
|
Authors() AuthorList
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,9 +14,11 @@
|
||||||
package page
|
package page
|
||||||
|
|
||||||
// AuthorList is a list of all authors and their metadata.
|
// AuthorList is a list of all authors and their metadata.
|
||||||
|
// Deprecated: Use taxonomies instead.
|
||||||
type AuthorList map[string]Author
|
type AuthorList map[string]Author
|
||||||
|
|
||||||
// Author contains details about the author of a page.
|
// Author contains details about the author of a page.
|
||||||
|
// Deprecated: Use taxonomies instead.
|
||||||
type Author struct {
|
type Author struct {
|
||||||
GivenName string
|
GivenName string
|
||||||
FamilyName string
|
FamilyName string
|
||||||
|
@ -41,4 +43,5 @@ type Author struct {
|
||||||
// - youtube
|
// - youtube
|
||||||
// - linkedin
|
// - linkedin
|
||||||
// - skype
|
// - skype
|
||||||
|
// Deprecated: Use taxonomies instead.
|
||||||
type AuthorSocial map[string]string
|
type AuthorSocial map[string]string
|
||||||
|
|
|
@ -79,10 +79,12 @@ func (p *nopPage) RSSLink() template.URL {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use taxonomies instead.
|
||||||
func (p *nopPage) Author() Author {
|
func (p *nopPage) Author() Author {
|
||||||
return Author{}
|
return Author{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use taxonomies instead.
|
||||||
func (p *nopPage) Authors() AuthorList {
|
func (p *nopPage) Authors() AuthorList {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,13 +108,13 @@ type Site interface {
|
||||||
// Returns the site config.
|
// Returns the site config.
|
||||||
Config() SiteConfig
|
Config() SiteConfig
|
||||||
|
|
||||||
// Author is deprecated and will be removed in a future release.
|
// Deprecated: Use taxonomies instead.
|
||||||
Author() map[string]interface{}
|
Author() map[string]interface{}
|
||||||
|
|
||||||
// Authors is deprecated and will be removed in a future release.
|
// Deprecated: Use taxonomies instead.
|
||||||
Authors() AuthorList
|
Authors() AuthorList
|
||||||
|
|
||||||
// Returns the social links for this site.
|
// Deprecated: Use .Site.Params instead.
|
||||||
Social() map[string]string
|
Social() map[string]string
|
||||||
|
|
||||||
// Deprecated: Use Config().Services.GoogleAnalytics instead.
|
// Deprecated: Use Config().Services.GoogleAnalytics instead.
|
||||||
|
@ -165,16 +165,19 @@ func (s *siteWrapper) Key() string {
|
||||||
return s.s.Language().Lang
|
return s.s.Language().Lang
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// // Deprecated: Use .Site.Params instead.
|
||||||
func (s *siteWrapper) Social() map[string]string {
|
func (s *siteWrapper) Social() map[string]string {
|
||||||
return s.s.Social()
|
return s.s.Social()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use taxonomies instead.
|
||||||
func (s *siteWrapper) Author() map[string]interface{} {
|
func (s *siteWrapper) Author() map[string]interface{} {
|
||||||
return s.s.Author()
|
return s.s.Author()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use taxonomies instead.
|
||||||
func (s *siteWrapper) Authors() AuthorList {
|
func (s *siteWrapper) Authors() AuthorList {
|
||||||
return AuthorList{}
|
return s.s.Authors()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated: Use .Site.Config.Services.GoogleAnalytics.ID instead.
|
// Deprecated: Use .Site.Config.Services.GoogleAnalytics.ID instead.
|
||||||
|
@ -321,14 +324,17 @@ type testSite struct {
|
||||||
l *langs.Language
|
l *langs.Language
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use taxonomies instead.
|
||||||
func (s testSite) Author() map[string]interface{} {
|
func (s testSite) Author() map[string]interface{} {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use taxonomies instead.
|
||||||
func (s testSite) Authors() AuthorList {
|
func (s testSite) Authors() AuthorList {
|
||||||
return AuthorList{}
|
return AuthorList{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use .Site.Params instead.
|
||||||
func (s testSite) Social() map[string]string {
|
func (s testSite) Social() map[string]string {
|
||||||
return make(map[string]string)
|
return make(map[string]string)
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,10 +127,12 @@ func (p *testPage) AlternativeOutputFormats() OutputFormats {
|
||||||
panic("testpage: not implemented")
|
panic("testpage: not implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use taxonomies instead.
|
||||||
func (p *testPage) Author() Author {
|
func (p *testPage) Author() Author {
|
||||||
return Author{}
|
return Author{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use taxonomies instead.
|
||||||
func (p *testPage) Authors() AuthorList {
|
func (p *testPage) Authors() AuthorList {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,18 +34,11 @@
|
||||||
{{ end }}{{ end }}
|
{{ end }}{{ end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
{{- /* Deprecate site.Social.facebook_admin in favor of site.Params.social.facebook_admin */}}
|
{{- /* Facebook Page Admin ID for Domain Insights */}}
|
||||||
{{- $facebookAdmin := "" }}
|
|
||||||
{{- with site.Params.social }}
|
{{- with site.Params.social }}
|
||||||
{{- if reflect.IsMap . }}
|
{{- if reflect.IsMap . }}
|
||||||
{{- $facebookAdmin = .facebook_admin }}
|
{{- with .facebook_admin }}
|
||||||
|
<meta property="fb:admins" content="{{ . }}" />
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- else }}
|
|
||||||
{{- with site.Social.facebook_admin }}
|
|
||||||
{{- $facebookAdmin = . }}
|
|
||||||
{{- warnf "The social key in site configuration is deprecated. Use params.social.facebook_admin instead." }}
|
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
{{- /* Facebook Page Admin ID for Domain Insights */}}
|
|
||||||
{{ with $facebookAdmin }}<meta property="fb:admins" content="{{ . }}" />{{ end }}
|
|
||||||
|
|
|
@ -8,23 +8,15 @@
|
||||||
<meta name="twitter:title" content="{{ .Title }}"/>
|
<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 -}}"/>
|
<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 := "" }}
|
{{- $twitterSite := "" }}
|
||||||
{{- with site.Params.social }}
|
{{- with site.Params.social }}
|
||||||
{{- if reflect.IsMap . }}
|
{{- if reflect.IsMap . }}
|
||||||
{{- $twitterSite = .twitter }}
|
{{- with .twitter }}
|
||||||
{{- 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 := . }}
|
{{- $content := . }}
|
||||||
{{- if not (strings.HasPrefix . "@") }}
|
{{- if not (strings.HasPrefix . "@") }}
|
||||||
{{- $content = printf "@%v" $twitterSite }}
|
{{- $content = printf "@%v" . }}
|
||||||
|
{{- end }}
|
||||||
|
<meta name="twitter:site" content="{{ $content }}"/>
|
||||||
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
<meta name="twitter:site" content="{{ $content }}"/>
|
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
Loading…
Reference in a new issue