Skip to content

Commit

Permalink
fix: deprecated .Site.IsMultiLingual .Site.Author warning
Browse files Browse the repository at this point in the history
fixes #463
  • Loading branch information
reuixiy committed Aug 27, 2024
1 parent d9fcef4 commit 5c626cb
Show file tree
Hide file tree
Showing 15 changed files with 73 additions and 67 deletions.
2 changes: 1 addition & 1 deletion assets/scss/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ $baseRelURL: "{{ "" | relURL | strings.TrimSuffix "/" }}";

// Components

{{ if and .Site.IsMultiLingual .Site.Params.enableLangToggle }}
{{ if and hugo.IsMultilingual .Site.Params.enableLangToggle }}
@import "components/multilingual";
{{ end }}

Expand Down
32 changes: 17 additions & 15 deletions config-examples/en/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -99,21 +99,6 @@ uglyURLs = false
[minify.tdewolff.html]
keepWhitespace = false

# Author’s information
[author]
# Name
name = "reuixiy"
# Email
email = "[email protected]"
# Motto or introduction
motto = "Viva La Vida"
# Avatar
avatar = "/icons/apple-touch-icon.png"
# Personal website, default: baseURL
website = "https://io-oi.me/"
# Twitter
twitter = "reuixiy"

# Related content
[related]
threshold = 80
Expand Down Expand Up @@ -1518,3 +1503,20 @@ uglyURLs = false
valine = "/npm/[email protected]/dist/Valine.min.js"
busuanzi = "https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"
utterances = "https://utteranc.es/client.js"


######################################
# Author’s information
[params.author]
# Name
name = "reuixiy"
# Email
email = "[email protected]"
# Motto or introduction
motto = "Viva La Vida"
# Avatar
avatar = "/icons/apple-touch-icon.png"
# Personal website, default: baseURL
website = "https://io-oi.me/"
# Twitter
twitter = "reuixiy"
32 changes: 17 additions & 15 deletions config-examples/zh-cn/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -97,21 +97,6 @@ uglyURLs = false
[minify.tdewolff.html]
keepWhitespace = false

# 作者信息
[author]
# 名字
name = "reuixiy"
# 邮箱
email = "[email protected]"
# 座右铭或简介
motto = "Viva La Vida"
# 头像
avatar = "/icons/apple-touch-icon.png"
# 网站(默认值:baseURL)
website = "https://io-oi.me/"
# 推特
twitter = "reuixiy"

# 相关文章
[related]
threshold = 80
Expand Down Expand Up @@ -1483,3 +1468,20 @@ uglyURLs = false
valine = "/npm/[email protected]/dist/Valine.min.js"
busuanzi = "https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"
utterances = "https://utteranc.es/client.js"


######################################
# 作者信息
[params.author]
# 名字
name = "reuixiy"
# 邮箱
email = "[email protected]"
# 座右铭或简介
motto = "Viva La Vida"
# 头像
avatar = "/icons/apple-touch-icon.png"
# 网站(默认值:baseURL)
website = "https://io-oi.me/"
# 推特
twitter = "reuixiy"
32 changes: 17 additions & 15 deletions config-examples/zh-tw/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -97,21 +97,6 @@ uglyURLs = false
[minify.tdewolff.html]
keepWhitespace = false

# 作者資訊
[author]
# 名字
name = "reuixiy"
# 郵箱
email = "[email protected]"
# 座右銘或簡介
motto = "Viva La Vida"
# 頭像
avatar = "/icons/apple-touch-icon.png"
# 網站(預設值:baseURL)
website = "https://io-oi.me/"
# 推特
twitter = "reuixiy"

# 相關文章
[related]
threshold = 80
Expand Down Expand Up @@ -1483,3 +1468,20 @@ uglyURLs = false
valine = "/npm/[email protected]/dist/Valine.min.js"
busuanzi = "https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"
utterances = "https://utteranc.es/client.js"


######################################
# 作者資訊
[params.author]
# 名字
name = "reuixiy"
# 郵箱
email = "[email protected]"
# 座右銘或簡介
motto = "Viva La Vida"
# 頭像
avatar = "/icons/apple-touch-icon.png"
# 網站(預設值:baseURL)
website = "https://io-oi.me/"
# 推特
twitter = "reuixiy"
4 changes: 2 additions & 2 deletions layouts/index.sectionsatom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
{{ with .OutputFormats.Get "SectionsAtom" -}}
<link rel="self" type="{{ .MediaType }}" href="{{ .Permalink }}" />
{{ end -}}
{{ with .Site.Author.name -}}
{{ with .Site.Params.author.name -}}
<author>
<name>{{ . }}</name>
<uri>{{ "" | absLangURL }}</uri>
{{ with $.Site.Author.email }}
{{ with $.Site.Params.author.email }}
<email>{{ . }}</email>
{{ end -}}
</author>
Expand Down
8 changes: 4 additions & 4 deletions layouts/index.sectionsrss.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
{{ with .Site.LanguageCode }}
<language>{{ . }}</language>
{{ end }}
{{ with .Site.Author.email }}
<managingEditor>{{ . }}{{ with $.Site.Author.name }} ({{ . }}){{ end }}</managingEditor>
{{ with .Site.Params.author.email }}
<managingEditor>{{ . }}{{ with $.Site.Params.author.name }} ({{ . }}){{ end }}</managingEditor>
{{ end }}
{{ with .Site.Author.email }}
<webMaster>{{ . }}{{ with $.Site.Author.name }} ({{ . }}){{ end }}</webMaster>
{{ with .Site.Params.author.email }}
<webMaster>{{ . }}{{ with $.Site.Params.author.name }} ({{ . }}){{ end }}</webMaster>
{{ end }}
{{ with .Site.Copyright }}
<copyright>{{ . | plainify | htmlUnescape }}</copyright>
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/components/multilingual.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if and .Site.IsMultiLingual .Site.Params.enableLangToggle -}}
{{- if and hugo.IsMultilingual .Site.Params.enableLangToggle -}}
{{- $hide := or (and .IsHome .Site.Params.hideLangToggleInHome) (and (not .IsHome) (and .Site.Params.autoHideLangToggle (not .IsTranslated))) -}}
{{- if not $hide -}}
<div id="lang-switcher">
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/components/post-gitinfo.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
{{ end }}
{{ if .Site.Params.displayEditLink }}
{{ with .Site.Params.repoEditURL }}
{{ $contentDir := (cond $.Site.IsMultiLingual (printf `/%s/` $.Site.Params.contentDir) "/content/") }}
{{ $contentDir := (cond hugo.IsMultilingual (printf `/%s/` $.Site.Params.contentDir) "/content/") }}
<div class="gitinfo-item edit">
<a href="{{ . }}{{ $contentDir }}{{ replace $path "\\" "/" }}{{ $.Site.Params.repoEditURLSuffix | default "" }}" target="_blank" rel="noopener">
{{- partial "utils/icon.html" (dict "$" $ "name" $.Site.Params.editIcon "class" "edit-icon") -}}
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
{{- end -}}

{{- if .Site.Params.displaySiteAuthorName -}}
&nbsp;{{- .Site.Author.name -}}
&nbsp;{{- .Site.Params.author.name -}}
{{- end -}}
</div>

Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<noscript><link rel="stylesheet" href="{{ . }}" /></noscript>
{{- end }}

<meta name="author" content="{{ .Params.author | default .Site.Author.name }}" />
<meta name="author" content="{{ .Params.author | default .Site.Params.author.name }}" />
{{- $description := .Description | default (partial "utils/summary.html" .) | default .Site.Params.siteDescription | plainify | htmlUnescape -}}
<meta name="description" content="{{ $description }}" />

Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
{{ end }}
{{ end }}
{{ else if eq .Identifier "lang-switcher" }}
{{ if and $.Site.IsMultiLingual $.Site.Params.enableLangToggle }}
{{ if and hugo.IsMultilingual $.Site.Params.enableLangToggle }}
{{ if eq $.Site.Params.headerLayout "flex" }}
{{ $switcher := partial "components/multilingual.html" $currentPage }}
{{ with $switcher }}
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/script.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
{{- $scripts = union $scripts (slice "js/dark-mode.js") -}}
{{- end -}}

{{- if and .Site.IsMultiLingual .Site.Params.enableLangToggle -}}
{{- if and hugo.IsMultilingual .Site.Params.enableLangToggle -}}
{{- $scripts = union $scripts (slice "js/multilingual.js") -}}
{{- end -}}

Expand Down
12 changes: 6 additions & 6 deletions layouts/partials/utils/author.html
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
{{- $author := dict -}}
{{- if .Params.original | default .Site.Params.original -}}
{{- with .Site.Author.name -}}
{{- with .Site.Params.author.name -}}
{{- $author = merge $author (dict "name" .) -}}
{{- end -}}
{{- with .Site.Author.email -}}
{{- with .Site.Params.author.email -}}
{{- $author = merge $author (dict "email" .) -}}
{{- end -}}
{{- with .Site.Author.motto -}}
{{- with .Site.Params.author.motto -}}
{{- $author = merge $author (dict "motto" .) -}}
{{- end -}}
{{- with .Site.Author.avatar -}}
{{- with .Site.Params.author.avatar -}}
{{- $author = merge $author (dict "avatar" .) -}}
{{- end -}}
{{- $baseURLWithLangFix := "" | absLangURL -}}
{{- with .Site.Author.website | default $baseURLWithLangFix -}}
{{- with .Site.Params.author.website | default $baseURLWithLangFix -}}
{{- $author = merge $author (dict "website" .) -}}
{{- end -}}
{{- with .Site.Copyright -}}
{{- $author = merge $author (dict "copyright" .) -}}
{{- end -}}
{{- with .Site.Author.twitter -}}
{{- with .Site.Params.author.twitter -}}
{{- $author = merge $author (dict "twitter" .) -}}
{{- end -}}
{{- else -}}
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/utils/open-graph.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<meta property="og:url" content="{{ $.Permalink }}" />
<meta property="og:site_name" content="{{ $.Site.Title }}" />
<meta property="og:locale" content="{{ $.Site.Language.Lang }}" />
{{- if and $.Site.IsMultiLingual $.IsTranslated -}}
{{- if and hugo.IsMultilingual $.IsTranslated -}}
{{- range $.Site.Languages -}}
{{ if ne .Lang $.Site.Language.Lang }}
<meta property="og:locale:alternate" content="{{ . }}" />
Expand Down
4 changes: 2 additions & 2 deletions layouts/partials/utils/tree-sections.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
{{- $.Scratch.Delete "sections" -}}
{{- $.Scratch.Delete "pages" -}}
{{- $contentDir := $.Site.Params.contentDir -}}
{{- template "treeSections" (dict "$" $ "path" (cond $.Site.IsMultiLingual (printf `./%s` $contentDir) (printf `./content`))) -}}
{{- template "treeSections" (dict "$" $ "path" (cond hugo.IsMultilingual (printf `./%s` $contentDir) (printf `./content`))) -}}

{{- define "treeSections" -}}
{{- $ := index . "$" -}}
{{- $path := .path -}}
{{- range (readDir $path) -}}
{{- $fileName := .Name -}}
{{- if .IsDir -}}
{{- $pagePath := (cond $.Site.IsMultiLingual (strings.TrimPrefix (printf `./%s` $.Site.Params.contentDir) (printf `%s/%s` $path $fileName)) (strings.TrimPrefix "./content" (printf `%s/%s` $path $fileName))) -}}
{{- $pagePath := (cond hugo.IsMultilingual (strings.TrimPrefix (printf `./%s` $.Site.Params.contentDir) (printf `%s/%s` $path $fileName)) (strings.TrimPrefix "./content" (printf `%s/%s` $path $fileName))) -}}
{{- with $.Site.GetPage $pagePath -}}
{{- if and (eq .Kind "section") (in $.Site.Params.mainSections .Section) -}}
{{- $.Scratch.Add "sections" (slice $fileName) -}}
Expand Down

0 comments on commit 5c626cb

Please sign in to comment.