diff --git a/exampleSite/config/_default/author.toml b/exampleSite/config/_default/author.toml deleted file mode 100644 index b99ea27e3..000000000 --- a/exampleSite/config/_default/author.toml +++ /dev/null @@ -1,21 +0,0 @@ -name = "HBS (Hugo Bootstrap Theme)" -# avatar = "images/profile.png" # Avatar image. Default to "images/profile.webp". -bio = "Fast, responsive, multipurpose, open source (MIT license) and feature-rich Hugo theme." -company = 'Company' -# company = 'Company' -location = "Earth" -# alternatives: -# location = "Earth" -# location = "Earth" -# about = "https://domain.tld" # The external about page. The internal about page will be used if not set. - -[params] - #layout = "compact" - -[social] - email = "razonyang@gmail.com" - github = "razonyang/hugo-theme-bootstrap" - twitter = "razonyang" - patreon = "razonyang" - paypal = "razonyang" - # rss = "" # Disable RSS link diff --git a/exampleSite/config/_default/params.toml b/exampleSite/config/_default/params.toml index 27d64241d..4abdb9389 100644 --- a/exampleSite/config/_default/params.toml +++ b/exampleSite/config/_default/params.toml @@ -333,3 +333,26 @@ paypal="razonyang" patreon="razonyang" # tipeee="yourtipeeeaccount-fr" # rss = "" # Disable RSS link + +[author] +name = "HBS (Hugo Bootstrap Theme)" +# avatar = "images/profile.png" # Avatar image. Default to "images/profile.webp". +bio = "Fast, responsive, multipurpose, open source (MIT license) and feature-rich Hugo theme." +company = 'Company' +# company = 'Company' +location = "Earth" +# alternatives: +# location = "Earth" +# location = "Earth" +# about = "https://domain.tld" # The external about page. The internal about page will be used if not set. + +[author.params] + #layout = "compact" + +[author.social] + email = "razonyang@gmail.com" + github = "razonyang/hugo-theme-bootstrap" + twitter = "razonyang" + patreon = "razonyang" + paypal = "razonyang" + # rss = "" # Disable RSS link diff --git a/exampleSite/content/docs/widgets/author/index.md b/exampleSite/content/docs/widgets/author/index.md index fb00927cd..b09578a52 100644 --- a/exampleSite/content/docs/widgets/author/index.md +++ b/exampleSite/content/docs/widgets/author/index.md @@ -24,10 +24,19 @@ The author widget is located in the sidebar, in order to introduce yourself brie -## Site Configuration +## Site Parameters -The configuration file is located in `config/_default/author.toml` by default. -You can turn it off by removing the `author` configuration. +{{% alert warning %}} +`config/_default/author.toml` is deprecated, please use `params.author` instead. +{{% /alert %}} + +```toml +// params.toml +[author] +name = "Foobar" +[author.params] +[author.social] +``` | Name | Type | Default | Description |---|:-:|:-:|--- @@ -41,3 +50,4 @@ You can turn it off by removing the `author` configuration. | `author.params` | Object | - | | `author.params.layout` | String | - | Optional values: `compact`. | `author.social` | Object | - | [Social Links]({{< ref "/docs/widgets/social-links" >}}). + diff --git a/exampleSite/content/docs/widgets/author/index.zh-hans.md b/exampleSite/content/docs/widgets/author/index.zh-hans.md index e572fb6a8..68e25512e 100644 --- a/exampleSite/content/docs/widgets/author/index.zh-hans.md +++ b/exampleSite/content/docs/widgets/author/index.zh-hans.md @@ -24,10 +24,19 @@ authors = ["RazonYang"] -## 站点配置 +## 站点参数 -默认地,配置文件位于 `config/_default/author.toml`。 -你可以通过移除 `author` 配置禁用小部件。 +{{% alert warning %}} +`config/_default/author.toml` 已被弃用,请使用 `params.author` 代替。 +{{% /alert %}} + +```toml +// params.toml +[author] +name = "Foobar" +[author.params] +[author.social] +``` | 名称 | 类型 | 默认值 | 描述 |---|:-:|:-:|--- diff --git a/exampleSite/content/docs/widgets/author/index.zh-hant.md b/exampleSite/content/docs/widgets/author/index.zh-hant.md index c83340325..15bf024ac 100644 --- a/exampleSite/content/docs/widgets/author/index.zh-hant.md +++ b/exampleSite/content/docs/widgets/author/index.zh-hant.md @@ -24,11 +24,19 @@ authors = ["RazonYang"] -## 網站配置 +## 網站參數 -默認地,設定檔位於 `config/_ default/author.toml`。 +{{% alert warning %}} +`config/_default/author.toml` 已被棄用,請使用 `params.author` 代替。 +{{% /alert %}} -你可以通過移除 `author` 配置禁用小部件。 +```toml +// params.toml +[author] +name = "Foobar" +[author.params] +[author.social] +``` | 名稱 | 類型 | 預設值 | 描述 |---|:-:|:-:|--- diff --git a/exampleSite/content/docs/widgets/social-links/index.md b/exampleSite/content/docs/widgets/social-links/index.md index 02e946748..acbc79c35 100644 --- a/exampleSite/content/docs/widgets/social-links/index.md +++ b/exampleSite/content/docs/widgets/social-links/index.md @@ -40,10 +40,10 @@ There are three places you can put social links to: top app bar, [Author Widget] ### Author Widget -Set up social links by editing a file `config/_default/author.toml` with the following content: +Set up social links by editing a file `config/_default/params.toml` with the following content: ```toml -[social] +[author.social] email = "user@domain.tld" github = "githubusername" ``` diff --git a/exampleSite/content/docs/widgets/social-links/index.zh-hans.md b/exampleSite/content/docs/widgets/social-links/index.zh-hans.md index 2e923388b..7e0ee613d 100644 --- a/exampleSite/content/docs/widgets/social-links/index.zh-hans.md +++ b/exampleSite/content/docs/widgets/social-links/index.zh-hans.md @@ -40,10 +40,10 @@ authors = ["RazonYang"] ### 作者小部件 -编辑 `config/_default/author.toml` 文件,并填写以下配置: +编辑 `config/_default/params.toml` 文件,并填写以下配置: ```toml -[social] +[author.social] email = "user@domain.tld" github = "githubusername" ``` diff --git a/exampleSite/content/docs/widgets/social-links/index.zh-hant.md b/exampleSite/content/docs/widgets/social-links/index.zh-hant.md index 0b9ca7fdc..f57cb79bc 100644 --- a/exampleSite/content/docs/widgets/social-links/index.zh-hant.md +++ b/exampleSite/content/docs/widgets/social-links/index.zh-hant.md @@ -40,10 +40,10 @@ authors = ["RazonYang"] ### 作者小部件 -編輯 `config/_default/author.toml` 文件,並填寫以下配置: +編輯 `config/_default/params.toml` 文件,並填寫以下配置: ```toml -[social] +[author.social] email = "user@domain.tld" github = "githubusername" ``` diff --git a/exampleSite/layouts/shortcodes/code/configuration-structure.html b/exampleSite/layouts/shortcodes/code/configuration-structure.html index 2147fd441..c2576a63f 100644 --- a/exampleSite/layouts/shortcodes/code/configuration-structure.html +++ b/exampleSite/layouts/shortcodes/code/configuration-structure.html @@ -1,6 +1,5 @@ ```text ├── _default -│ ├── author.toml │ ├── config.toml │ ├── config.zh-hans.toml │ ├── config.zh-hant.toml diff --git a/layouts/partials/rss.html b/layouts/partials/rss.html index 0890f1d4d..cf986243e 100644 --- a/layouts/partials/rss.html +++ b/layouts/partials/rss.html @@ -1,4 +1,36 @@ {{/* Source: https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/_default/rss.xml */}} +{{- /* Deprecate site.Author.email in favor of site.Params.author.email */}} +{{- $authorEmail := "" }} +{{- with site.Params.author }} + {{- if reflect.IsMap . }} + {{- with .email }} + {{- $authorEmail = . }} + {{- end }} + {{- end }} +{{- else }} + {{- with site.Author.email }} + {{- $authorEmail = . }} + {{- warnf "The author key in site configuration is deprecated. Use params.author.email instead." }} + {{- end }} +{{- end }} + +{{- /* Deprecate site.Author.name in favor of site.Params.author.name */}} +{{- $authorName := "" }} +{{- with site.Params.author }} + {{- if reflect.IsMap . }} + {{- with .name }} + {{- $authorName = . }} + {{- end }} + {{- else }} + {{- $authorName = . }} + {{- end }} +{{- else }} + {{- with site.Author.name }} + {{- $authorName = . }} + {{- warnf "The author key in site configuration is deprecated. Use params.author.name instead." }} + {{- end }} +{{- end }} + {{- $pctx := . -}} {{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}} {{- $pages := slice -}} @@ -18,10 +50,10 @@ {{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }} {{ .Permalink }} Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{.}} {{ end }}{{ end }}on {{ .Site.Title }} - Hugo -- gohugo.io{{ with .Site.LanguageCode }} - {{.}}{{end}}{{ with .Site.Author.email }} - {{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}{{end}}{{ with .Site.Author.email }} - {{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}{{end}} + Hugo + {{ site.Language.LanguageCode }}{{ with $authorEmail }} + {{.}}{{ with $authorName }} ({{ . }}){{ end }}{{ end }}{{ with $authorEmail }} + {{ . }}{{ with $authorName }} ({{ . }}){{ end }}{{ end }} {{- partial "helpers/copyright" . }}{{ if not .Date.IsZero }} {{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}{{ end }} {{- with .OutputFormats.Get "RSS" -}} @@ -32,7 +64,7 @@ {{ .Title }} {{ .Permalink }} {{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }} - {{ with .Site.Author.email }}{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}{{end}} + {{- with $authorEmail }}{{ . }}{{ with $authorName }} ({{ . }}){{ end }}{{ end }} {{ .Permalink }} {{- printf "" .Summary | safeHTML }} {{- if default false $.Site.Params.feeds.content }} diff --git a/layouts/partials/sidebar/profile.html b/layouts/partials/sidebar/profile.html index 80c0d9861..3e543f82f 100644 --- a/layouts/partials/sidebar/profile.html +++ b/layouts/partials/sidebar/profile.html @@ -1,5 +1,10 @@ -{{- if .Site.Author }} -{{- $layout := default "" .Site.Author.params.layout }} +{{- $author := site.Params.author }} +{{- with site.Author }} + {{- $author = . }} + {{- warnf "The author key in site configuration is deprecated. Use params.author instead." }} +{{- end }} +{{- if $author }} +{{- $layout := default "" $author.params.layout }} {{- if eq $layout "compact" }} {{- partial "sidebar/profile/compact" . }} {{- else }} diff --git a/layouts/partials/sidebar/profile/avatar.html b/layouts/partials/sidebar/profile/avatar.html index daf54901d..719568a7c 100644 --- a/layouts/partials/sidebar/profile/avatar.html +++ b/layouts/partials/sidebar/profile/avatar.html @@ -1,4 +1,9 @@ -{{- with .Site.Author -}} +{{- $author := site.Params.author }} +{{- with site.Author }} + {{- $author = . }} + {{- warnf "The author key in site configuration is deprecated. Use params.author instead." }} +{{- end }} +{{- with $author -}} {{- $attributes := printf "data-viewer-invisible" | safeHTMLAttr -}} {{- partial "helpers/image" (dict "filename" (default "images/profile.webp" .avatar) "class" "profile-avatar rounded-circle" "alt" .name "resources" $.Resources "attributes" $attributes) -}} {{- end -}} diff --git a/layouts/partials/sidebar/profile/meta.html b/layouts/partials/sidebar/profile/meta.html index 743f47565..bb7222a91 100644 --- a/layouts/partials/sidebar/profile/meta.html +++ b/layouts/partials/sidebar/profile/meta.html @@ -1,4 +1,9 @@ -{{- with .Site.Author -}} +{{- $author := site.Params.author }} +{{- with site.Author }} + {{- $author = . }} + {{- warnf "The author key in site configuration is deprecated. Use params.author instead." }} +{{- end }} +{{- with $author -}}
{{ .name }}
{{- with .bio -}}
{{ . }}
diff --git a/layouts/partials/sidebar/profile/social-links.html b/layouts/partials/sidebar/profile/social-links.html index 58dfb11b9..3f480303d 100644 --- a/layouts/partials/sidebar/profile/social-links.html +++ b/layouts/partials/sidebar/profile/social-links.html @@ -1,3 +1,8 @@ -{{- with .Site.Author.social -}} +{{- $author := site.Params.author }} +{{- with site.Author }} + {{- $author = . }} + {{- warnf "The author key in site configuration is deprecated. Use params.author instead." }} +{{- end }} +{{- with $author.social -}} {{- partial "helpers/social-links" (dict "class" "mt-1 justify-content-around" "links" . "size" "fa-2x" "OutputFormats" $.OutputFormats "home" ($.GetPage "/") "params" $.Site.Params) -}} {{- end -}}