Skip to content
This repository has been archived by the owner on Mar 9, 2022. It is now read-only.

Support Array-style post author #153

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions layouts/_default/summary.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ <h1 class="single-title" itemprop="name headline">

{{- /* Meta */ -}}
<div class="post-meta">
{{- $author := $params.author | default .Site.Author.name | default (T "author") -}}
{{- $authorLink := $params.authorlink | default .Site.Author.link | default .Site.Home.RelPermalink -}}
{{- $author := $params.author | default .Site.Params.Author.name | default (T "author") -}}
{{- $authorLink := $params.authorlink | default .Site.Params.Author.link | default .Site.Home.RelPermalink -}}
<span class="post-author">
{{- $options := dict "Class" "author" "Destination" $authorLink "Title" "Author" "Rel" "author" "Icon" (dict "Class" "fas fa-user-circle fa-fw") "Content" $author -}}
{{- partial "plugin/link.html" $options -}}
Expand Down Expand Up @@ -72,4 +72,4 @@ <h1 class="single-title" itemprop="name headline">
</div>
{{- end -}}
</div>
</article>
</article>
6 changes: 3 additions & 3 deletions layouts/index.rss.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
{{- . -}}
</language>
{{- end -}}
{{- with .Site.Author.email -}}
{{- with .Site.Params.Author.email -}}
<managingEditor>
{{- . }}{{ with $.Site.Author.name }} ({{ . }}){{ end -}}
{{- . }}{{ with $.Site.Params.Author.name }} ({{ . }}){{ end -}}
</managingEditor>
<webMaster>
{{- . }}{{ with $.Site.Author.name }} ({{ . }}){{ end -}}
{{- . }}{{ with $.Site.Params.Author.name }} ({{ . }}){{ end -}}
</webMaster>
{{- end -}}
{{- with .Site.Copyright -}}
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

{{- /* Author */ -}}
{{- if ne .Site.Params.footer.author false -}}
<span class="author" itemprop="copyrightHolder">&nbsp;<a href="{{ $.Site.Author.link | default .Site.Home.RelPermalink }}" target="_blank" rel="noopener noreferrer">{{ .Site.Author.name }}</a></span>
<span class="author" itemprop="copyrightHolder">&nbsp;<a href="{{ $.Site.Params.Author.link | default .Site.Home.RelPermalink }}" target="_blank" rel="noopener noreferrer">{{ .Site.Params.Author.name }}</a></span>
{{- end -}}

{{- /* License */ -}}
Expand Down
13 changes: 9 additions & 4 deletions layouts/partials/head/seo.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
{{- with .Site.LanguageCode -}}
"inLanguage": "{{ . }}",
{{- end -}}
{{- with .Site.Author.name -}}
{{- with .Site.Params.Author.name -}}
"author": {
"@type": "Person",
"name": {{ . | safeHTML }}
Expand Down Expand Up @@ -122,7 +122,7 @@
{{- with .Site.Copyright -}}
"license": {{ . | safeHTML }},
{{- end -}}
{{- $publisher := .Params.author | default .Site.Author.name | default (T "author") | dict "name" -}}
{{- $publisher := .Params.author | default .Site.Params.Author.name | default (T "author") | dict "name" -}}
{{- $publisher = $params.seo.publisher | default dict | merge $publisher -}}
"publisher": {
"@type": "Organization",
Expand All @@ -141,10 +141,15 @@
{{- end -}}
{{- end -}}
},
{{- with .Params.author | default .Site.Author.name | default (T "author") -}}
{{- with .Params.author | default .Site.Params.Author.name | default (T "author") -}}
"author": {
"@type": "Person",
"name": {{ . | safeHTML }}
"name":
{{ if (eq "[]string" (printf "%T" .) ) }}
{{ delimit . ", " }}
{{ else }}
{{ . }}
{{ end }}
},
{{- end -}}
"description": {{ .Description | safeHTML }}
Expand Down
4 changes: 2 additions & 2 deletions layouts/partials/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
{{- if .Site.Menus.main -}}
<span class="menu-item delimiter"></span>
{{- end -}}
{{- if .Site.IsMultiLingual -}}
{{- if hugo.IsMultilingual -}}
<a href="javascript:void(0);" class="menu-item language" title="{{ T "selectLanguage" }}">
{{- .Language.LanguageName -}}
<i class="fas fa-chevron-right fa-fw"></i>
Expand Down Expand Up @@ -148,7 +148,7 @@
<a href="javascript:void(0);" class="menu-item theme-switch" title="{{ T "switchTheme" }}">
<i class="fas fa-adjust fa-fw"></i>
</a>
{{- if .Site.IsMultiLingual -}}
{{- if hugo.IsMultilingual -}}
<a href="javascript:void(0);" class="menu-item" title="{{ T "selectLanguage" }}">
{{- .Language.LanguageName -}}
<i class="fas fa-chevron-right fa-fw"></i>
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/home/profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{{- if $avatar -}}
<div class="home-avatar">
{{- $menus := $.Site.Menus.main | default slice -}}
{{- $avatarAlt := $profile.avatarAlt | default .Site.Author.name -}}
{{- $avatarAlt := $profile.avatarAlt | default .Site.Params.Author.name -}}
{{- with index $menus 0 -}}
{{- $url := .URL | relLangURL -}}
{{- with .Page -}}
Expand Down
4 changes: 2 additions & 2 deletions layouts/partials/init.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

{{- /* CodeIT theme version detection */ -}}
{{- $VERSION := "0.2.X" -}}
{{- if eq .Site .Sites.First -}}
{{- if eq .Site .Sites.Default -}}
{{- if not .Site.Params.version -}}
{{- errorf "Configuration Error 配置文件错误\n\nYou haven't configured the CodeIT version param correctly yet. See https://codeit.suntprogramator.dev/theme-documentation-basics/#basic-configuration\n你还没有正确配置 CodeIT 的版本参数. 参考 https://hugoCodeIT.com/zh-cn/theme-documentation-basics/#basic-configuration\n" -}}
{{- else if ne .Site.Params.version $VERSION -}}
Expand Down Expand Up @@ -31,7 +31,7 @@
{{- else if eq .Params.comment false -}}
{{- .Scratch.Set "comment" dict -}}
{{- end -}}
{{- else if eq .Site .Sites.First -}}
{{- else if eq .Site .Sites.Default -}}
{{- warnf "\n\nCurrent environment is \"development\". The \"comment system\", \"CDN\" and \"fingerprint\" will be disabled.\n当前运行环境是 \"development\". \"评论系统\", \"CDN\" 和 \"fingerprint\" 不会启用.\n" -}}
{{- end -}}

Expand Down
8 changes: 6 additions & 2 deletions layouts/partials/plugin/link.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
{{- partial "plugin/icon.html" . -}}
{{- end -}}
{{- with .Content -}}
{{- . | safeHTML -}}
{{ if (eq "[]string" (printf "%T" .) ) }}
{{ delimit . ", " }}
{{ else }}
{{ . }}
{{ end }}
{{- end -}}
</a>
</a>
4 changes: 2 additions & 2 deletions layouts/partials/rss/item.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- $params := .Page.Params | merge .Site.Params.Page | merge (dict "author" .Site.Author.name "email" .Site.Author.email) -}}
{{- $params := .Page.Params | merge .Site.Params.Page | merge (dict "author" .Site.Params.Author.name "email" .Site.Params.Author.email) -}}
<item>
<title>
{{- .Page.Title -}}
Expand Down Expand Up @@ -40,4 +40,4 @@
{{- $content | replaceRE `<figure[^>]*>.*</figure>` "" | replaceRE `<img[^>]*( /)?>` "" | safeHTML -}}
{{- "]]>" | safeHTML -}}
</description>
</item>
</item>
6 changes: 3 additions & 3 deletions layouts/posts/rss.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
{{- . -}}
</language>
{{- end -}}
{{- with .Site.Author.email -}}
{{- with .Site.Params.Author.email -}}
<managingEditor>
{{- . }}{{ with $.Site.Author.name }} ({{ . }}){{ end -}}
{{- . }}{{ with $.Site.Params.Author.name }} ({{ . }}){{ end -}}
</managingEditor>
<webMaster>
{{- . }}{{ with $.Site.Author.name }} ({{ . }}){{ end -}}
{{- . }}{{ with $.Site.Params.Author.name }} ({{ . }}){{ end -}}
</webMaster>
{{- end -}}
{{- with .Site.Copyright -}}
Expand Down
4 changes: 2 additions & 2 deletions layouts/posts/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ <h2 class="single-subtitle">{{ . }}</h2>
{{- /* Meta */ -}}
<div class="post-meta">
<div class="post-meta-line">
{{- $author := $params.author | default .Site.Author.name | default (T "author") -}}
{{- $authorLink := $params.authorlink | default .Site.Author.link | default .Site.Home.RelPermalink -}}
{{- $author := $params.author | default .Site.Params.Author.name | default (T "author") -}}
{{- $authorLink := $params.authorlink | default .Site.Params.Author.link | default .Site.Home.RelPermalink -}}
<span class="post-author">
{{- $options := dict "Class" "author" "Destination" $authorLink "Title" "Author" "Rel" "author" "Icon" (dict "Class" "fas fa-user-circle fa-fw") "Content" $author -}}
{{- partial "plugin/link.html" $options -}}
Expand Down
4 changes: 2 additions & 2 deletions layouts/shortcodes/version.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
{{- $type := .Get 1 | default "new" | lower -}}
{{- $label := T $type -}}
{{- $color := cond (eq $type "changed") "ff9101" "00b1ff" | cond (eq $type "deleted") "ff5252" -}}
{{- $pathTemplate := cond .Site.IsMultiLingual (printf "svg/version/%%v-%%v.%v.svg" .Page.Language.Lang) "svg/version/%v-%v.svg" -}}
{{- $pathTemplate := cond hugo.IsMultilingual (printf "svg/version/%%v-%%v.%v.svg" .Page.Language.Lang) "svg/version/%v-%v.svg" -}}
{{- $path := printf $pathTemplate $version $type -}}
{{- $resource := resources.Get "svg/version.template.svg" -}}
{{- $resource = $resource | resources.ExecuteAsTemplate $path (dict "version" $version "label" $label "color" $color) | minify -}}
{{- $alt := printf "CodeIT %v | %v" $label $version -}}
<a href="{{ $url }}" rel="noopener noreferrer" target="_blank">
{{- dict "Src" $resource.RelPermalink "Alt" $alt "Class" "version" | partial "plugin/image.html" -}}
</a>
</a>
6 changes: 3 additions & 3 deletions layouts/taxonomy/rss.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
{{- . -}}
</language>
{{- end -}}
{{- with .Site.Author.email -}}
{{- with .Site.Params.Author.email -}}
<managingEditor>
{{- . }}{{ with $.Site.Author.name }} ({{ . }}){{ end -}}
{{- . }}{{ with $.Site.Params.Author.name }} ({{ . }}){{ end -}}
</managingEditor>
<webMaster>
{{- . }}{{ with $.Site.Author.name }} ({{ . }}){{ end -}}
{{- . }}{{ with $.Site.Params.Author.name }} ({{ . }}){{ end -}}
</webMaster>
{{- end -}}
{{- with .Site.Copyright -}}
Expand Down
Loading