From 5b2e093c916fe3f9739b131317a7af4d023d93f5 Mon Sep 17 00:00:00 2001 From: Razon Yang Date: Tue, 31 Oct 2023 22:09:24 +0800 Subject: [PATCH] fix(social): replace site.Social with site.Params.social (#1002) --- exampleSite/config/_default/params.toml | 38 +++++++++++++++++++ exampleSite/config/_default/social.toml | 36 ------------------ .../docs/configuration/site-params/index.md | 1 + .../site-params/index.zh-hans.md | 1 + .../site-params/index.zh-hant.md | 1 + .../content/docs/configuration/site/index.md | 1 - .../docs/configuration/site/index.zh-hans.md | 1 - .../docs/configuration/site/index.zh-hant.md | 1 - .../docs/widgets/social-links/index.md | 3 +- .../widgets/social-links/index.zh-hans.md | 3 +- .../widgets/social-links/index.zh-hant.md | 5 ++- .../code/configuration-structure.html | 1 - layouts/partials/footer/social-links.html | 9 ++++- 13 files changed, 56 insertions(+), 45 deletions(-) delete mode 100644 exampleSite/config/_default/social.toml diff --git a/exampleSite/config/_default/params.toml b/exampleSite/config/_default/params.toml index 8c1e3f702..47c816af5 100644 --- a/exampleSite/config/_default/params.toml +++ b/exampleSite/config/_default/params.toml @@ -295,3 +295,41 @@ expand = false # Expand docs navigations. [feeds] # content = true + +[social] +email = "user@domain.tld" +# facebook = "yourfacebookusername" +github = "razonyang/hugo-theme-bootstrap" +# gitlab = "yourgitlabusername" +# linkedin = "yourlinkedinusername" +# xing = "yourxingusername" +# stackoverflow = "yourstackoverflowuserid" +twitter = "razonyang" +# weibo = "yourweibousername" +# zhihu = "yourzhihuusername" +# instagram = "yourinstagramusername" +# itchio = "youritchiousername" +# quora = "yourquorausername" +# tumblr = "yourtumblrusername" +# reddit = "yourredditusername" +# telegram = "yourtelegramusername" +# qq = "yourqqnumber" +# dockerhub = "yourdockerhubusername" +# bitbucket = "yourbitbucketworkspaceid" +# kaggle = "yourkaggleusername" +# medium = "yourmediumusername" # Medium username or custom domain(e.g. https://razonyang.com). +# lastfm = "yourlastfmusername" +# bilibili = "yourbilibiliuserid" +# youtube = "youryoutubechannelid" +# discord = "yourdiscordinvitecode" +# discourse = "https://yourforum.tld" +# facebookgroup = "yourfacebookgroupname" +# tiktok = "yourtiktokusername" +# artstation = "yourartstationusername" +# pinterest = "yourpinterestusername" +# mastodon = "yourmastodonusername" +# liberapay = "yourliberapayaccount" +paypal="razonyang" +patreon="razonyang" +# tipeee="yourtipeeeaccount-fr" +# rss = "" # Disable RSS link diff --git a/exampleSite/config/_default/social.toml b/exampleSite/config/_default/social.toml deleted file mode 100644 index a1092f2bb..000000000 --- a/exampleSite/config/_default/social.toml +++ /dev/null @@ -1,36 +0,0 @@ -email = "user@domain.tld" -# facebook = "yourfacebookusername" -github = "razonyang/hugo-theme-bootstrap" -# gitlab = "yourgitlabusername" -# linkedin = "yourlinkedinusername" -# xing = "yourxingusername" -# stackoverflow = "yourstackoverflowuserid" -twitter = "razonyang" -# weibo = "yourweibousername" -# zhihu = "yourzhihuusername" -# instagram = "yourinstagramusername" -# itchio = "youritchiousername" -# quora = "yourquorausername" -# tumblr = "yourtumblrusername" -# reddit = "yourredditusername" -# telegram = "yourtelegramusername" -# qq = "yourqqnumber" -# dockerhub = "yourdockerhubusername" -# bitbucket = "yourbitbucketworkspaceid" -# kaggle = "yourkaggleusername" -# medium = "yourmediumusername" # Medium username or custom domain(e.g. https://razonyang.com). -# lastfm = "yourlastfmusername" -# bilibili = "yourbilibiliuserid" -# youtube = "youryoutubechannelid" -# discord = "yourdiscordinvitecode" -# discourse = "https://yourforum.tld" -# facebookgroup = "yourfacebookgroupname" -# tiktok = "yourtiktokusername" -# artstation = "yourartstationusername" -# pinterest = "yourpinterestusername" -# mastodon = "yourmastodonusername" -# liberapay = "yourliberapayaccount" -paypal="razonyang" -patreon="razonyang" -# tipeee="yourtipeeeaccount-fr" -# rss = "" # Disable RSS link diff --git a/exampleSite/content/docs/configuration/site-params/index.md b/exampleSite/content/docs/configuration/site-params/index.md index 74f5aeed3..a47b2df35 100644 --- a/exampleSite/content/docs/configuration/site-params/index.md +++ b/exampleSite/content/docs/configuration/site-params/index.md @@ -72,6 +72,7 @@ The site parameters are located in `config/_default/params.toml` by default. | `fontSize.extraSmall` | String | `.8rem` | Extra small font size. | `fontSize.large` | String | `1.1rem` | Large font size. | `fontSize.extraLarge` | String | `1.2rem` | Extra large font size. +| `social` | Object | - | [Social Links]({{< ref "/docs/widgets/social-links" >}}). | `socialShare` | Boolean | `true` | Turn on/off built-on social share button. | `searchBar` | Boolean | `true` | Turn on/off built-on search bar. | `archive` | Object | - | [Archive]({{< ref "/docs/layouts/archives" >}}). diff --git a/exampleSite/content/docs/configuration/site-params/index.zh-hans.md b/exampleSite/content/docs/configuration/site-params/index.zh-hans.md index 680fa961c..fdceaf580 100644 --- a/exampleSite/content/docs/configuration/site-params/index.zh-hans.md +++ b/exampleSite/content/docs/configuration/site-params/index.zh-hans.md @@ -73,6 +73,7 @@ authors = ["RazonYang"] | `fontSize.extraSmall` | String | `.8rem` | 更小的字体 | `fontSize.large` | String | `1.1rem` | 大字体 | `fontSize.extraLarge` | String | `1.2rem` | 更大的字体 +| `social` | Object | - | [社交链接]({{< ref "/docs/widgets/social-links" >}})。 | `socialShare` | Boolean | `true` | 启用/禁用内置的分享按钮 | `searchBar` | Boolean | `true` | 启用/禁用搜索栏 | **Archive** diff --git a/exampleSite/content/docs/configuration/site-params/index.zh-hant.md b/exampleSite/content/docs/configuration/site-params/index.zh-hant.md index 5f88ab9e6..7b3d497df 100644 --- a/exampleSite/content/docs/configuration/site-params/index.zh-hant.md +++ b/exampleSite/content/docs/configuration/site-params/index.zh-hant.md @@ -73,6 +73,7 @@ authors = ["RazonYang"] | `fontSize.extraSmall` | String | `.8rem` | 更小的字體 | `fontSize.large` | String | `1.1rem` | 大字體 | `fontSize.extraLarge` | String | `1.2rem` | 更大的字體 +| `social` | Object | - | [社交鏈接]({{< ref "/docs/widgets/social-links" >}})。 | `socialShare` | Boolean | `true` | 啟用/禁用內置的分享按鈕 | `searchBar` | Boolean | `true` | 啟用/禁用搜索欄 | **Archive** diff --git a/exampleSite/content/docs/configuration/site/index.md b/exampleSite/content/docs/configuration/site/index.md index 867c94957..29c396166 100644 --- a/exampleSite/content/docs/configuration/site/index.md +++ b/exampleSite/content/docs/configuration/site/index.md @@ -35,7 +35,6 @@ The site configuration is located in `config/_default/config.toml` by default. | `enableRobotsTXT` | Boolean | `true` | | `disqusShortname` | String | - | [Disqus]({{< ref "/docs/widgets/comments#disqus" >}}) shortname. | `googleAnalytics` | String | - | Google Analytics, both of universal analytics and GA4 are supported. -| `social` | Object | - | [Social Links]({{< ref "/docs/widgets/social-links" >}}). | `author` | Object | - | [Author Widget]({{< ref "/docs/widgets/author" >}}). See also [All Configuration Settings](https://gohugo.io/getting-started/configuration/#all-configuration-settings). diff --git a/exampleSite/content/docs/configuration/site/index.zh-hans.md b/exampleSite/content/docs/configuration/site/index.zh-hans.md index fb1113379..149c2ea1b 100644 --- a/exampleSite/content/docs/configuration/site/index.zh-hans.md +++ b/exampleSite/content/docs/configuration/site/index.zh-hans.md @@ -35,7 +35,6 @@ authors = ["RazonYang"] | `enableRobotsTXT` | Boolean | `true` | | `disqusShortname` | String | - | [Disqus]({{< ref "/docs/widgets/comments#disqus" >}}) shortname。 | `googleAnalytics` | String | - | Google Analytics, both of universal analytics and GA4 are supported. -| `social` | Object | - | [社交链接]({{< ref "/docs/widgets/social-links" >}})。 | `author` | Object | - | [作者小部件]({{< ref "/docs/widgets/author" >}})。 请参阅 [All Configuration Settings](https://gohugo.io/getting-started/configuration/#all-configuration-settings)。 diff --git a/exampleSite/content/docs/configuration/site/index.zh-hant.md b/exampleSite/content/docs/configuration/site/index.zh-hant.md index 029580f92..b036b68d4 100644 --- a/exampleSite/content/docs/configuration/site/index.zh-hant.md +++ b/exampleSite/content/docs/configuration/site/index.zh-hant.md @@ -35,7 +35,6 @@ authors = ["RazonYang"] | `enableRobotsTXT` | Boolean | `true` | | `disqusShortname` | String | - | [Disqus]({{< ref "/docs/widgets/comments#disqus" >}}) shortname。 | `googleAnalytics` | String | - | Google Analytics, both of universal analytics and GA4 are supported. -| `social` | Object | - | [社交鏈接]({{< ref "/docs/widgets/social-links" >}})。 | `author` | Object | - | [作者小部件]({{< ref "/docs/widgets/author" >}})。 請參閱 [All Configuration Settings](https://gohugo.io/getting-started/configuration/#all-configuration-settings)。 diff --git a/exampleSite/content/docs/widgets/social-links/index.md b/exampleSite/content/docs/widgets/social-links/index.md index 64492fe8f..02e946748 100644 --- a/exampleSite/content/docs/widgets/social-links/index.md +++ b/exampleSite/content/docs/widgets/social-links/index.md @@ -50,9 +50,10 @@ Set up social links by editing a file `config/_default/author.toml` with the fol ### Footer -Set up social links by creating a file `config/_default/social.toml` with the following content: +Set up social links by putting the following content in `config/_default/params.toml`. ```toml +[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 20edead7a..2e923388b 100644 --- a/exampleSite/content/docs/widgets/social-links/index.zh-hans.md +++ b/exampleSite/content/docs/widgets/social-links/index.zh-hans.md @@ -50,9 +50,10 @@ authors = ["RazonYang"] ### 页脚 -创建 `config/_default/social.toml` 文件,并填写以下配置: +将以下内容放到 `config/_default/params.toml` 文件,以于页脚设置社交链接: ```toml +[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 6b4cc0403..0b9ca7fdc 100644 --- a/exampleSite/content/docs/widgets/social-links/index.zh-hant.md +++ b/exampleSite/content/docs/widgets/social-links/index.zh-hant.md @@ -50,9 +50,10 @@ authors = ["RazonYang"] ### 頁腳 -建立 `config/_default/social.toml` 檔案,並填寫以下配置: +將以下內容放到 `config/_default/params.toml` 文件,以於頁腳設置社交鏈接: ```toml +[social] email = "user@domain.tld" github = "githubusername" ``` @@ -96,5 +97,5 @@ github = "githubusername" | `paypal` | Paypal 使用者名稱 | | `patreon` | Patreon 使用者名稱 | | `tipeee` | Tipeee 使用者名稱 | -| `rss` | 空字符串以禁用 RSS 链接 | +| `rss` | 空字符串以禁用 RSS 鏈接 | | `website` | 網站 URL | diff --git a/exampleSite/layouts/shortcodes/code/configuration-structure.html b/exampleSite/layouts/shortcodes/code/configuration-structure.html index 6b7bcee25..2147fd441 100644 --- a/exampleSite/layouts/shortcodes/code/configuration-structure.html +++ b/exampleSite/layouts/shortcodes/code/configuration-structure.html @@ -13,7 +13,6 @@ │ ├── params.zh-hans.toml │ ├── params.zh-hant.toml │ ├── server.toml -│ └── social.toml └── production ├── config.toml └── params.toml diff --git a/layouts/partials/footer/social-links.html b/layouts/partials/footer/social-links.html index c91ec0145..bc6b17969 100644 --- a/layouts/partials/footer/social-links.html +++ b/layouts/partials/footer/social-links.html @@ -1,5 +1,12 @@ +{{- $social := default dict site.Params.social }} +{{- if not $social }} + {{- with site.Social }} + {{- warnf "The social configuration and the social key in site configuration are deprecated. Use params.social instead." }} + {{- $social = . }} + {{- end }} +{{- end }} {{- partial "helpers/social-links" (dict - "links" .Site.Social + "links" $social "size" (cond (isset .Site.Menus "footer") "" "fa-2x") "class" (cond (isset .Site.Menus "footer") "justify-content-between mb-2 mt-3" "mb-2 mt-3") "linkClass" "p-0 me-1 mb-2"